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 9e0f138..a695542 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -480,19 +480,25 @@ namespace OpenSim.Framework | |||
480 | /// </summary> | 480 | /// </summary> |
481 | /// <param name="data"></param> | 481 | /// <param name="data"></param> |
482 | /// <returns></returns> | 482 | /// <returns></returns> |
483 | |||
483 | public static string Md5Hash(string data) | 484 | public static string Md5Hash(string data) |
484 | { | 485 | { |
485 | byte[] dataMd5 = ComputeMD5Hash(data); | 486 | return Md5Hash(data, Encoding.Default); |
487 | } | ||
488 | |||
489 | public static string Md5Hash(string data, Encoding encoding) | ||
490 | { | ||
491 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
486 | StringBuilder sb = new StringBuilder(); | 492 | StringBuilder sb = new StringBuilder(); |
487 | for (int i = 0; i < dataMd5.Length; i++) | 493 | for (int i = 0; i < dataMd5.Length; i++) |
488 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 494 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
489 | return sb.ToString(); | 495 | return sb.ToString(); |
490 | } | 496 | } |
491 | 497 | ||
492 | private static byte[] ComputeMD5Hash(string data) | 498 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
493 | { | 499 | { |
494 | MD5 md5 = MD5.Create(); | 500 | MD5 md5 = MD5.Create(); |
495 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 501 | return md5.ComputeHash(encoding.GetBytes(data)); |
496 | } | 502 | } |
497 | 503 | ||
498 | /// <summary> | 504 | /// <summary> |
@@ -500,6 +506,12 @@ namespace OpenSim.Framework | |||
500 | /// </summary> | 506 | /// </summary> |
501 | /// <param name="data"></param> | 507 | /// <param name="data"></param> |
502 | /// <returns></returns> | 508 | /// <returns></returns> |
509 | |||
510 | public static string SHA1Hash(string data, Encoding enc) | ||
511 | { | ||
512 | return SHA1Hash(enc.GetBytes(data)); | ||
513 | } | ||
514 | |||
503 | public static string SHA1Hash(string data) | 515 | public static string SHA1Hash(string data) |
504 | { | 516 | { |
505 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 517 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1104,19 +1116,19 @@ namespace OpenSim.Framework | |||
1104 | { | 1116 | { |
1105 | string os = String.Empty; | 1117 | string os = String.Empty; |
1106 | 1118 | ||
1107 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1119 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1108 | { | 1120 | // { |
1109 | os = Environment.OSVersion.ToString(); | 1121 | // os = Environment.OSVersion.ToString(); |
1110 | } | 1122 | // } |
1111 | else | 1123 | // else |
1112 | { | 1124 | // { |
1113 | os = ReadEtcIssue(); | 1125 | // os = ReadEtcIssue(); |
1114 | } | 1126 | // } |
1115 | 1127 | // | |
1116 | if (os.Length > 45) | 1128 | // if (os.Length > 45) |
1117 | { | 1129 | // { |
1118 | os = os.Substring(0, 45); | 1130 | // os = os.Substring(0, 45); |
1119 | } | 1131 | // } |
1120 | 1132 | ||
1121 | return os; | 1133 | return os; |
1122 | } | 1134 | } |
@@ -1249,7 +1261,7 @@ namespace OpenSim.Framework | |||
1249 | 1261 | ||
1250 | public static Guid GetHashGuid(string data, string salt) | 1262 | public static Guid GetHashGuid(string data, string salt) |
1251 | { | 1263 | { |
1252 | byte[] hash = ComputeMD5Hash(data + salt); | 1264 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1253 | 1265 | ||
1254 | //string s = BitConverter.ToString(hash); | 1266 | //string s = BitConverter.ToString(hash); |
1255 | 1267 | ||