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