diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index cef756c..9227708 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -409,19 +409,25 @@ namespace OpenSim.Framework | |||
409 | /// </summary> | 409 | /// </summary> |
410 | /// <param name="data"></param> | 410 | /// <param name="data"></param> |
411 | /// <returns></returns> | 411 | /// <returns></returns> |
412 | |||
412 | public static string Md5Hash(string data) | 413 | public static string Md5Hash(string data) |
413 | { | 414 | { |
414 | byte[] dataMd5 = ComputeMD5Hash(data); | 415 | return Md5Hash(data, Encoding.Default); |
416 | } | ||
417 | |||
418 | public static string Md5Hash(string data, Encoding encoding) | ||
419 | { | ||
420 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
415 | StringBuilder sb = new StringBuilder(); | 421 | StringBuilder sb = new StringBuilder(); |
416 | for (int i = 0; i < dataMd5.Length; i++) | 422 | for (int i = 0; i < dataMd5.Length; i++) |
417 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 423 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
418 | return sb.ToString(); | 424 | return sb.ToString(); |
419 | } | 425 | } |
420 | 426 | ||
421 | private static byte[] ComputeMD5Hash(string data) | 427 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
422 | { | 428 | { |
423 | MD5 md5 = MD5.Create(); | 429 | MD5 md5 = MD5.Create(); |
424 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 430 | return md5.ComputeHash(encoding.GetBytes(data)); |
425 | } | 431 | } |
426 | 432 | ||
427 | /// <summary> | 433 | /// <summary> |
@@ -1161,7 +1167,7 @@ namespace OpenSim.Framework | |||
1161 | 1167 | ||
1162 | public static Guid GetHashGuid(string data, string salt) | 1168 | public static Guid GetHashGuid(string data, string salt) |
1163 | { | 1169 | { |
1164 | byte[] hash = ComputeMD5Hash(data + salt); | 1170 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1165 | 1171 | ||
1166 | //string s = BitConverter.ToString(hash); | 1172 | //string s = BitConverter.ToString(hash); |
1167 | 1173 | ||