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 efa4a7b..02da7f4 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -478,19 +478,25 @@ namespace OpenSim.Framework
478 /// </summary> 478 /// </summary>
479 /// <param name="data"></param> 479 /// <param name="data"></param>
480 /// <returns></returns> 480 /// <returns></returns>
481
481 public static string Md5Hash(string data) 482 public static string Md5Hash(string data)
482 { 483 {
483 byte[] dataMd5 = ComputeMD5Hash(data); 484 return Md5Hash(data, Encoding.Default);
485 }
486
487 public static string Md5Hash(string data, Encoding encoding)
488 {
489 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
484 StringBuilder sb = new StringBuilder(); 490 StringBuilder sb = new StringBuilder();
485 for (int i = 0; i < dataMd5.Length; i++) 491 for (int i = 0; i < dataMd5.Length; i++)
486 sb.AppendFormat("{0:x2}", dataMd5[i]); 492 sb.AppendFormat("{0:x2}", dataMd5[i]);
487 return sb.ToString(); 493 return sb.ToString();
488 } 494 }
489 495
490 private static byte[] ComputeMD5Hash(string data) 496 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
491 { 497 {
492 MD5 md5 = MD5.Create(); 498 MD5 md5 = MD5.Create();
493 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 499 return md5.ComputeHash(encoding.GetBytes(data));
494 } 500 }
495 501
496 /// <summary> 502 /// <summary>
@@ -498,6 +504,12 @@ namespace OpenSim.Framework
498 /// </summary> 504 /// </summary>
499 /// <param name="data"></param> 505 /// <param name="data"></param>
500 /// <returns></returns> 506 /// <returns></returns>
507
508 public static string SHA1Hash(string data, Encoding enc)
509 {
510 return SHA1Hash(enc.GetBytes(data));
511 }
512
501 public static string SHA1Hash(string data) 513 public static string SHA1Hash(string data)
502 { 514 {
503 return SHA1Hash(Encoding.Default.GetBytes(data)); 515 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -1102,19 +1114,19 @@ namespace OpenSim.Framework
1102 { 1114 {
1103 string os = String.Empty; 1115 string os = String.Empty;
1104 1116
1105 if (Environment.OSVersion.Platform != PlatformID.Unix) 1117// if (Environment.OSVersion.Platform != PlatformID.Unix)
1106 { 1118// {
1107 os = Environment.OSVersion.ToString(); 1119// os = Environment.OSVersion.ToString();
1108 } 1120// }
1109 else 1121// else
1110 { 1122// {
1111 os = ReadEtcIssue(); 1123// os = ReadEtcIssue();
1112 } 1124// }
1113 1125//
1114 if (os.Length > 45) 1126// if (os.Length > 45)
1115 { 1127// {
1116 os = os.Substring(0, 45); 1128// os = os.Substring(0, 45);
1117 } 1129// }
1118 1130
1119 return os; 1131 return os;
1120 } 1132 }
@@ -1247,7 +1259,7 @@ namespace OpenSim.Framework
1247 1259
1248 public static Guid GetHashGuid(string data, string salt) 1260 public static Guid GetHashGuid(string data, string salt)
1249 { 1261 {
1250 byte[] hash = ComputeMD5Hash(data + salt); 1262 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1251 1263
1252 //string s = BitConverter.ToString(hash); 1264 //string s = BitConverter.ToString(hash);
1253 1265