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 6a15734..19d40db 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -542,19 +542,25 @@ namespace OpenSim.Framework | |||
542 | /// </summary> | 542 | /// </summary> |
543 | /// <param name="data"></param> | 543 | /// <param name="data"></param> |
544 | /// <returns></returns> | 544 | /// <returns></returns> |
545 | |||
545 | public static string Md5Hash(string data) | 546 | public static string Md5Hash(string data) |
546 | { | 547 | { |
547 | byte[] dataMd5 = ComputeMD5Hash(data); | 548 | return Md5Hash(data, Encoding.Default); |
549 | } | ||
550 | |||
551 | public static string Md5Hash(string data, Encoding encoding) | ||
552 | { | ||
553 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
548 | StringBuilder sb = new StringBuilder(); | 554 | StringBuilder sb = new StringBuilder(); |
549 | for (int i = 0; i < dataMd5.Length; i++) | 555 | for (int i = 0; i < dataMd5.Length; i++) |
550 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 556 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
551 | return sb.ToString(); | 557 | return sb.ToString(); |
552 | } | 558 | } |
553 | 559 | ||
554 | private static byte[] ComputeMD5Hash(string data) | 560 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
555 | { | 561 | { |
556 | MD5 md5 = MD5.Create(); | 562 | MD5 md5 = MD5.Create(); |
557 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 563 | return md5.ComputeHash(encoding.GetBytes(data)); |
558 | } | 564 | } |
559 | 565 | ||
560 | /// <summary> | 566 | /// <summary> |
@@ -562,6 +568,12 @@ namespace OpenSim.Framework | |||
562 | /// </summary> | 568 | /// </summary> |
563 | /// <param name="data"></param> | 569 | /// <param name="data"></param> |
564 | /// <returns></returns> | 570 | /// <returns></returns> |
571 | |||
572 | public static string SHA1Hash(string data, Encoding enc) | ||
573 | { | ||
574 | return SHA1Hash(enc.GetBytes(data)); | ||
575 | } | ||
576 | |||
565 | public static string SHA1Hash(string data) | 577 | public static string SHA1Hash(string data) |
566 | { | 578 | { |
567 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 579 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1303,19 +1315,19 @@ namespace OpenSim.Framework | |||
1303 | { | 1315 | { |
1304 | string os = String.Empty; | 1316 | string os = String.Empty; |
1305 | 1317 | ||
1306 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1318 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1307 | { | 1319 | // { |
1308 | os = Environment.OSVersion.ToString(); | 1320 | // os = Environment.OSVersion.ToString(); |
1309 | } | 1321 | // } |
1310 | else | 1322 | // else |
1311 | { | 1323 | // { |
1312 | os = ReadEtcIssue(); | 1324 | // os = ReadEtcIssue(); |
1313 | } | 1325 | // } |
1314 | 1326 | // | |
1315 | if (os.Length > 45) | 1327 | // if (os.Length > 45) |
1316 | { | 1328 | // { |
1317 | os = os.Substring(0, 45); | 1329 | // os = os.Substring(0, 45); |
1318 | } | 1330 | // } |
1319 | 1331 | ||
1320 | return os; | 1332 | return os; |
1321 | } | 1333 | } |
@@ -1447,7 +1459,7 @@ namespace OpenSim.Framework | |||
1447 | 1459 | ||
1448 | public static Guid GetHashGuid(string data, string salt) | 1460 | public static Guid GetHashGuid(string data, string salt) |
1449 | { | 1461 | { |
1450 | byte[] hash = ComputeMD5Hash(data + salt); | 1462 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1451 | 1463 | ||
1452 | //string s = BitConverter.ToString(hash); | 1464 | //string s = BitConverter.ToString(hash); |
1453 | 1465 | ||