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