diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-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 38cb3a6..1a383ae 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -481,19 +481,25 @@ namespace OpenSim.Framework | |||
481 | /// </summary> | 481 | /// </summary> |
482 | /// <param name="data"></param> | 482 | /// <param name="data"></param> |
483 | /// <returns></returns> | 483 | /// <returns></returns> |
484 | |||
484 | public static string Md5Hash(string data) | 485 | public static string Md5Hash(string data) |
485 | { | 486 | { |
486 | byte[] dataMd5 = ComputeMD5Hash(data); | 487 | return Md5Hash(data, Encoding.Default); |
488 | } | ||
489 | |||
490 | public static string Md5Hash(string data, Encoding encoding) | ||
491 | { | ||
492 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
487 | StringBuilder sb = new StringBuilder(); | 493 | StringBuilder sb = new StringBuilder(); |
488 | for (int i = 0; i < dataMd5.Length; i++) | 494 | for (int i = 0; i < dataMd5.Length; i++) |
489 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 495 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
490 | return sb.ToString(); | 496 | return sb.ToString(); |
491 | } | 497 | } |
492 | 498 | ||
493 | private static byte[] ComputeMD5Hash(string data) | 499 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
494 | { | 500 | { |
495 | MD5 md5 = MD5.Create(); | 501 | MD5 md5 = MD5.Create(); |
496 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 502 | return md5.ComputeHash(encoding.GetBytes(data)); |
497 | } | 503 | } |
498 | 504 | ||
499 | /// <summary> | 505 | /// <summary> |
@@ -501,6 +507,12 @@ namespace OpenSim.Framework | |||
501 | /// </summary> | 507 | /// </summary> |
502 | /// <param name="data"></param> | 508 | /// <param name="data"></param> |
503 | /// <returns></returns> | 509 | /// <returns></returns> |
510 | |||
511 | public static string SHA1Hash(string data, Encoding enc) | ||
512 | { | ||
513 | return SHA1Hash(enc.GetBytes(data)); | ||
514 | } | ||
515 | |||
504 | public static string SHA1Hash(string data) | 516 | public static string SHA1Hash(string data) |
505 | { | 517 | { |
506 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 518 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1111,19 +1123,19 @@ namespace OpenSim.Framework | |||
1111 | { | 1123 | { |
1112 | string os = String.Empty; | 1124 | string os = String.Empty; |
1113 | 1125 | ||
1114 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1126 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1115 | { | 1127 | // { |
1116 | os = Environment.OSVersion.ToString(); | 1128 | // os = Environment.OSVersion.ToString(); |
1117 | } | 1129 | // } |
1118 | else | 1130 | // else |
1119 | { | 1131 | // { |
1120 | os = ReadEtcIssue(); | 1132 | // os = ReadEtcIssue(); |
1121 | } | 1133 | // } |
1122 | 1134 | // | |
1123 | if (os.Length > 45) | 1135 | // if (os.Length > 45) |
1124 | { | 1136 | // { |
1125 | os = os.Substring(0, 45); | 1137 | // os = os.Substring(0, 45); |
1126 | } | 1138 | // } |
1127 | 1139 | ||
1128 | return os; | 1140 | return os; |
1129 | } | 1141 | } |
@@ -1255,7 +1267,7 @@ namespace OpenSim.Framework | |||
1255 | 1267 | ||
1256 | public static Guid GetHashGuid(string data, string salt) | 1268 | public static Guid GetHashGuid(string data, string salt) |
1257 | { | 1269 | { |
1258 | byte[] hash = ComputeMD5Hash(data + salt); | 1270 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1259 | 1271 | ||
1260 | //string s = BitConverter.ToString(hash); | 1272 | //string s = BitConverter.ToString(hash); |
1261 | 1273 | ||