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 b84673b..87a53ff 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -583,19 +583,25 @@ namespace OpenSim.Framework | |||
583 | /// </summary> | 583 | /// </summary> |
584 | /// <param name="data"></param> | 584 | /// <param name="data"></param> |
585 | /// <returns></returns> | 585 | /// <returns></returns> |
586 | |||
586 | public static string Md5Hash(string data) | 587 | public static string Md5Hash(string data) |
587 | { | 588 | { |
588 | byte[] dataMd5 = ComputeMD5Hash(data); | 589 | return Md5Hash(data, Encoding.Default); |
590 | } | ||
591 | |||
592 | public static string Md5Hash(string data, Encoding encoding) | ||
593 | { | ||
594 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
589 | StringBuilder sb = new StringBuilder(); | 595 | StringBuilder sb = new StringBuilder(); |
590 | for (int i = 0; i < dataMd5.Length; i++) | 596 | for (int i = 0; i < dataMd5.Length; i++) |
591 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 597 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
592 | return sb.ToString(); | 598 | return sb.ToString(); |
593 | } | 599 | } |
594 | 600 | ||
595 | private static byte[] ComputeMD5Hash(string data) | 601 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
596 | { | 602 | { |
597 | MD5 md5 = MD5.Create(); | 603 | MD5 md5 = MD5.Create(); |
598 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 604 | return md5.ComputeHash(encoding.GetBytes(data)); |
599 | } | 605 | } |
600 | 606 | ||
601 | /// <summary> | 607 | /// <summary> |
@@ -603,6 +609,12 @@ namespace OpenSim.Framework | |||
603 | /// </summary> | 609 | /// </summary> |
604 | /// <param name="data"></param> | 610 | /// <param name="data"></param> |
605 | /// <returns></returns> | 611 | /// <returns></returns> |
612 | |||
613 | public static string SHA1Hash(string data, Encoding enc) | ||
614 | { | ||
615 | return SHA1Hash(enc.GetBytes(data)); | ||
616 | } | ||
617 | |||
606 | public static string SHA1Hash(string data) | 618 | public static string SHA1Hash(string data) |
607 | { | 619 | { |
608 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 620 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1344,19 +1356,19 @@ namespace OpenSim.Framework | |||
1344 | { | 1356 | { |
1345 | string os = String.Empty; | 1357 | string os = String.Empty; |
1346 | 1358 | ||
1347 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1359 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1348 | { | 1360 | // { |
1349 | os = Environment.OSVersion.ToString(); | 1361 | // os = Environment.OSVersion.ToString(); |
1350 | } | 1362 | // } |
1351 | else | 1363 | // else |
1352 | { | 1364 | // { |
1353 | os = ReadEtcIssue(); | 1365 | // os = ReadEtcIssue(); |
1354 | } | 1366 | // } |
1355 | 1367 | // | |
1356 | if (os.Length > 45) | 1368 | // if (os.Length > 45) |
1357 | { | 1369 | // { |
1358 | os = os.Substring(0, 45); | 1370 | // os = os.Substring(0, 45); |
1359 | } | 1371 | // } |
1360 | 1372 | ||
1361 | return os; | 1373 | return os; |
1362 | } | 1374 | } |
@@ -1488,7 +1500,7 @@ namespace OpenSim.Framework | |||
1488 | 1500 | ||
1489 | public static Guid GetHashGuid(string data, string salt) | 1501 | public static Guid GetHashGuid(string data, string salt) |
1490 | { | 1502 | { |
1491 | byte[] hash = ComputeMD5Hash(data + salt); | 1503 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1492 | 1504 | ||
1493 | //string s = BitConverter.ToString(hash); | 1505 | //string s = BitConverter.ToString(hash); |
1494 | 1506 | ||