diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 039b926..fce8999 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -440,20 +440,30 @@ namespace OpenSim.Framework | |||
440 | } | 440 | } |
441 | 441 | ||
442 | /// <summary> | 442 | /// <summary> |
443 | /// Return an SHA1 hash of the given string | 443 | /// Return an SHA1 hash |
444 | /// </summary> | 444 | /// </summary> |
445 | /// <param name="data"></param> | 445 | /// <param name="data"></param> |
446 | /// <returns></returns> | 446 | /// <returns></returns> |
447 | public static string SHA1Hash(string data) | 447 | public static string SHA1Hash(string data) |
448 | { | 448 | { |
449 | return SHA1Hash(Encoding.Default.GetBytes(data)); | ||
450 | } | ||
451 | |||
452 | /// <summary> | ||
453 | /// Return an SHA1 hash | ||
454 | /// </summary> | ||
455 | /// <param name="data"></param> | ||
456 | /// <returns></returns> | ||
457 | public static string SHA1Hash(byte[] data) | ||
458 | { | ||
449 | byte[] hash = ComputeSHA1Hash(data); | 459 | byte[] hash = ComputeSHA1Hash(data); |
450 | return BitConverter.ToString(hash).Replace("-", String.Empty); | 460 | return BitConverter.ToString(hash).Replace("-", String.Empty); |
451 | } | 461 | } |
452 | 462 | ||
453 | private static byte[] ComputeSHA1Hash(string src) | 463 | private static byte[] ComputeSHA1Hash(byte[] src) |
454 | { | 464 | { |
455 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); | 465 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); |
456 | return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); | 466 | return SHA1.ComputeHash(src); |
457 | } | 467 | } |
458 | 468 | ||
459 | public static int fast_distance2d(int x, int y) | 469 | public static int fast_distance2d(int x, int y) |