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 d9148fb..8e325d7 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -501,19 +501,25 @@ namespace OpenSim.Framework | |||
501 | /// </summary> | 501 | /// </summary> |
502 | /// <param name="data"></param> | 502 | /// <param name="data"></param> |
503 | /// <returns></returns> | 503 | /// <returns></returns> |
504 | |||
504 | public static string Md5Hash(string data) | 505 | public static string Md5Hash(string data) |
505 | { | 506 | { |
506 | byte[] dataMd5 = ComputeMD5Hash(data); | 507 | return Md5Hash(data, Encoding.Default); |
508 | } | ||
509 | |||
510 | public static string Md5Hash(string data, Encoding encoding) | ||
511 | { | ||
512 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
507 | StringBuilder sb = new StringBuilder(); | 513 | StringBuilder sb = new StringBuilder(); |
508 | for (int i = 0; i < dataMd5.Length; i++) | 514 | for (int i = 0; i < dataMd5.Length; i++) |
509 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 515 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
510 | return sb.ToString(); | 516 | return sb.ToString(); |
511 | } | 517 | } |
512 | 518 | ||
513 | private static byte[] ComputeMD5Hash(string data) | 519 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
514 | { | 520 | { |
515 | MD5 md5 = MD5.Create(); | 521 | MD5 md5 = MD5.Create(); |
516 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 522 | return md5.ComputeHash(encoding.GetBytes(data)); |
517 | } | 523 | } |
518 | 524 | ||
519 | /// <summary> | 525 | /// <summary> |
@@ -521,6 +527,12 @@ namespace OpenSim.Framework | |||
521 | /// </summary> | 527 | /// </summary> |
522 | /// <param name="data"></param> | 528 | /// <param name="data"></param> |
523 | /// <returns></returns> | 529 | /// <returns></returns> |
530 | |||
531 | public static string SHA1Hash(string data, Encoding enc) | ||
532 | { | ||
533 | return SHA1Hash(enc.GetBytes(data)); | ||
534 | } | ||
535 | |||
524 | public static string SHA1Hash(string data) | 536 | public static string SHA1Hash(string data) |
525 | { | 537 | { |
526 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 538 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1189,19 +1201,19 @@ namespace OpenSim.Framework | |||
1189 | { | 1201 | { |
1190 | string os = String.Empty; | 1202 | string os = String.Empty; |
1191 | 1203 | ||
1192 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1204 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1193 | { | 1205 | // { |
1194 | os = Environment.OSVersion.ToString(); | 1206 | // os = Environment.OSVersion.ToString(); |
1195 | } | 1207 | // } |
1196 | else | 1208 | // else |
1197 | { | 1209 | // { |
1198 | os = ReadEtcIssue(); | 1210 | // os = ReadEtcIssue(); |
1199 | } | 1211 | // } |
1200 | 1212 | // | |
1201 | if (os.Length > 45) | 1213 | // if (os.Length > 45) |
1202 | { | 1214 | // { |
1203 | os = os.Substring(0, 45); | 1215 | // os = os.Substring(0, 45); |
1204 | } | 1216 | // } |
1205 | 1217 | ||
1206 | return os; | 1218 | return os; |
1207 | } | 1219 | } |
@@ -1333,7 +1345,7 @@ namespace OpenSim.Framework | |||
1333 | 1345 | ||
1334 | public static Guid GetHashGuid(string data, string salt) | 1346 | public static Guid GetHashGuid(string data, string salt) |
1335 | { | 1347 | { |
1336 | byte[] hash = ComputeMD5Hash(data + salt); | 1348 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1337 | 1349 | ||
1338 | //string s = BitConverter.ToString(hash); | 1350 | //string s = BitConverter.ToString(hash); |
1339 | 1351 | ||