aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs46
1 files changed, 29 insertions, 17 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index b3ec5c2..d2797e6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -448,19 +448,25 @@ namespace OpenSim.Framework
448 /// </summary> 448 /// </summary>
449 /// <param name="data"></param> 449 /// <param name="data"></param>
450 /// <returns></returns> 450 /// <returns></returns>
451
451 public static string Md5Hash(string data) 452 public static string Md5Hash(string data)
452 { 453 {
453 byte[] dataMd5 = ComputeMD5Hash(data); 454 return Md5Hash(data, Encoding.Default);
455 }
456
457 public static string Md5Hash(string data, Encoding encoding)
458 {
459 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
454 StringBuilder sb = new StringBuilder(); 460 StringBuilder sb = new StringBuilder();
455 for (int i = 0; i < dataMd5.Length; i++) 461 for (int i = 0; i < dataMd5.Length; i++)
456 sb.AppendFormat("{0:x2}", dataMd5[i]); 462 sb.AppendFormat("{0:x2}", dataMd5[i]);
457 return sb.ToString(); 463 return sb.ToString();
458 } 464 }
459 465
460 private static byte[] ComputeMD5Hash(string data) 466 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
461 { 467 {
462 MD5 md5 = MD5.Create(); 468 MD5 md5 = MD5.Create();
463 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 469 return md5.ComputeHash(encoding.GetBytes(data));
464 } 470 }
465 471
466 /// <summary> 472 /// <summary>
@@ -468,6 +474,12 @@ namespace OpenSim.Framework
468 /// </summary> 474 /// </summary>
469 /// <param name="data"></param> 475 /// <param name="data"></param>
470 /// <returns></returns> 476 /// <returns></returns>
477
478 public static string SHA1Hash(string data, Encoding enc)
479 {
480 return SHA1Hash(enc.GetBytes(data));
481 }
482
471 public static string SHA1Hash(string data) 483 public static string SHA1Hash(string data)
472 { 484 {
473 return SHA1Hash(Encoding.Default.GetBytes(data)); 485 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -1072,19 +1084,19 @@ namespace OpenSim.Framework
1072 { 1084 {
1073 string os = String.Empty; 1085 string os = String.Empty;
1074 1086
1075 if (Environment.OSVersion.Platform != PlatformID.Unix) 1087// if (Environment.OSVersion.Platform != PlatformID.Unix)
1076 { 1088// {
1077 os = Environment.OSVersion.ToString(); 1089// os = Environment.OSVersion.ToString();
1078 } 1090// }
1079 else 1091// else
1080 { 1092// {
1081 os = ReadEtcIssue(); 1093// os = ReadEtcIssue();
1082 } 1094// }
1083 1095//
1084 if (os.Length > 45) 1096// if (os.Length > 45)
1085 { 1097// {
1086 os = os.Substring(0, 45); 1098// os = os.Substring(0, 45);
1087 } 1099// }
1088 1100
1089 return os; 1101 return os;
1090 } 1102 }
@@ -1217,7 +1229,7 @@ namespace OpenSim.Framework
1217 1229
1218 public static Guid GetHashGuid(string data, string salt) 1230 public static Guid GetHashGuid(string data, string salt)
1219 { 1231 {
1220 byte[] hash = ComputeMD5Hash(data + salt); 1232 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1221 1233
1222 //string s = BitConverter.ToString(hash); 1234 //string s = BitConverter.ToString(hash);
1223 1235