diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 21cfc09..0b2fbb9 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -431,19 +431,25 @@ namespace OpenSim.Framework | |||
431 | /// </summary> | 431 | /// </summary> |
432 | /// <param name="data"></param> | 432 | /// <param name="data"></param> |
433 | /// <returns></returns> | 433 | /// <returns></returns> |
434 | |||
434 | public static string Md5Hash(string data) | 435 | public static string Md5Hash(string data) |
435 | { | 436 | { |
436 | byte[] dataMd5 = ComputeMD5Hash(data); | 437 | return Md5Hash(data, Encoding.Default); |
438 | } | ||
439 | |||
440 | public static string Md5Hash(string data, Encoding encoding) | ||
441 | { | ||
442 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
437 | StringBuilder sb = new StringBuilder(); | 443 | StringBuilder sb = new StringBuilder(); |
438 | for (int i = 0; i < dataMd5.Length; i++) | 444 | for (int i = 0; i < dataMd5.Length; i++) |
439 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 445 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
440 | return sb.ToString(); | 446 | return sb.ToString(); |
441 | } | 447 | } |
442 | 448 | ||
443 | private static byte[] ComputeMD5Hash(string data) | 449 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
444 | { | 450 | { |
445 | MD5 md5 = MD5.Create(); | 451 | MD5 md5 = MD5.Create(); |
446 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 452 | return md5.ComputeHash(encoding.GetBytes(data)); |
447 | } | 453 | } |
448 | 454 | ||
449 | /// <summary> | 455 | /// <summary> |
@@ -451,6 +457,12 @@ namespace OpenSim.Framework | |||
451 | /// </summary> | 457 | /// </summary> |
452 | /// <param name="data"></param> | 458 | /// <param name="data"></param> |
453 | /// <returns></returns> | 459 | /// <returns></returns> |
460 | |||
461 | public static string SHA1Hash(string data, Encoding enc) | ||
462 | { | ||
463 | return SHA1Hash(enc.GetBytes(data)); | ||
464 | } | ||
465 | |||
454 | public static string SHA1Hash(string data) | 466 | public static string SHA1Hash(string data) |
455 | { | 467 | { |
456 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 468 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1055,19 +1067,19 @@ namespace OpenSim.Framework | |||
1055 | { | 1067 | { |
1056 | string os = String.Empty; | 1068 | string os = String.Empty; |
1057 | 1069 | ||
1058 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1070 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1059 | { | 1071 | // { |
1060 | os = Environment.OSVersion.ToString(); | 1072 | // os = Environment.OSVersion.ToString(); |
1061 | } | 1073 | // } |
1062 | else | 1074 | // else |
1063 | { | 1075 | // { |
1064 | os = ReadEtcIssue(); | 1076 | // os = ReadEtcIssue(); |
1065 | } | 1077 | // } |
1066 | 1078 | // | |
1067 | if (os.Length > 45) | 1079 | // if (os.Length > 45) |
1068 | { | 1080 | // { |
1069 | os = os.Substring(0, 45); | 1081 | // os = os.Substring(0, 45); |
1070 | } | 1082 | // } |
1071 | 1083 | ||
1072 | return os; | 1084 | return os; |
1073 | } | 1085 | } |
@@ -1200,7 +1212,7 @@ namespace OpenSim.Framework | |||
1200 | 1212 | ||
1201 | public static Guid GetHashGuid(string data, string salt) | 1213 | public static Guid GetHashGuid(string data, string salt) |
1202 | { | 1214 | { |
1203 | byte[] hash = ComputeMD5Hash(data + salt); | 1215 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1204 | 1216 | ||
1205 | //string s = BitConverter.ToString(hash); | 1217 | //string s = BitConverter.ToString(hash); |
1206 | 1218 | ||