diff options
-rw-r--r-- | OpenSim/Framework/Util.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 |
2 files changed, 11 insertions, 5 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 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1ccf76e..45af13a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -6939,7 +6939,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6939 | public LSL_String llMD5String(string src, int nonce) | 6939 | public LSL_String llMD5String(string src, int nonce) |
6940 | { | 6940 | { |
6941 | m_host.AddScriptLPS(1); | 6941 | m_host.AddScriptLPS(1); |
6942 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); | 6942 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); |
6943 | } | 6943 | } |
6944 | 6944 | ||
6945 | public LSL_String llSHA1String(string src) | 6945 | public LSL_String llSHA1String(string src) |