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 7f0850f..0852b49 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -516,19 +516,25 @@ namespace OpenSim.Framework | |||
516 | /// </summary> | 516 | /// </summary> |
517 | /// <param name="data"></param> | 517 | /// <param name="data"></param> |
518 | /// <returns></returns> | 518 | /// <returns></returns> |
519 | |||
519 | public static string Md5Hash(string data) | 520 | public static string Md5Hash(string data) |
520 | { | 521 | { |
521 | byte[] dataMd5 = ComputeMD5Hash(data); | 522 | return Md5Hash(data, Encoding.Default); |
523 | } | ||
524 | |||
525 | public static string Md5Hash(string data, Encoding encoding) | ||
526 | { | ||
527 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
522 | StringBuilder sb = new StringBuilder(); | 528 | StringBuilder sb = new StringBuilder(); |
523 | for (int i = 0; i < dataMd5.Length; i++) | 529 | for (int i = 0; i < dataMd5.Length; i++) |
524 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 530 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
525 | return sb.ToString(); | 531 | return sb.ToString(); |
526 | } | 532 | } |
527 | 533 | ||
528 | private static byte[] ComputeMD5Hash(string data) | 534 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
529 | { | 535 | { |
530 | MD5 md5 = MD5.Create(); | 536 | MD5 md5 = MD5.Create(); |
531 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 537 | return md5.ComputeHash(encoding.GetBytes(data)); |
532 | } | 538 | } |
533 | 539 | ||
534 | /// <summary> | 540 | /// <summary> |
@@ -536,6 +542,12 @@ namespace OpenSim.Framework | |||
536 | /// </summary> | 542 | /// </summary> |
537 | /// <param name="data"></param> | 543 | /// <param name="data"></param> |
538 | /// <returns></returns> | 544 | /// <returns></returns> |
545 | |||
546 | public static string SHA1Hash(string data, Encoding enc) | ||
547 | { | ||
548 | return SHA1Hash(enc.GetBytes(data)); | ||
549 | } | ||
550 | |||
539 | public static string SHA1Hash(string data) | 551 | public static string SHA1Hash(string data) |
540 | { | 552 | { |
541 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 553 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1277,19 +1289,19 @@ namespace OpenSim.Framework | |||
1277 | { | 1289 | { |
1278 | string os = String.Empty; | 1290 | string os = String.Empty; |
1279 | 1291 | ||
1280 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1292 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1281 | { | 1293 | // { |
1282 | os = Environment.OSVersion.ToString(); | 1294 | // os = Environment.OSVersion.ToString(); |
1283 | } | 1295 | // } |
1284 | else | 1296 | // else |
1285 | { | 1297 | // { |
1286 | os = ReadEtcIssue(); | 1298 | // os = ReadEtcIssue(); |
1287 | } | 1299 | // } |
1288 | 1300 | // | |
1289 | if (os.Length > 45) | 1301 | // if (os.Length > 45) |
1290 | { | 1302 | // { |
1291 | os = os.Substring(0, 45); | 1303 | // os = os.Substring(0, 45); |
1292 | } | 1304 | // } |
1293 | 1305 | ||
1294 | return os; | 1306 | return os; |
1295 | } | 1307 | } |
@@ -1421,7 +1433,7 @@ namespace OpenSim.Framework | |||
1421 | 1433 | ||
1422 | public static Guid GetHashGuid(string data, string salt) | 1434 | public static Guid GetHashGuid(string data, string salt) |
1423 | { | 1435 | { |
1424 | byte[] hash = ComputeMD5Hash(data + salt); | 1436 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1425 | 1437 | ||
1426 | //string s = BitConverter.ToString(hash); | 1438 | //string s = BitConverter.ToString(hash); |
1427 | 1439 | ||