aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 5c7797a..74551ea 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -481,19 +481,25 @@ namespace OpenSim.Framework
481 /// </summary> 481 /// </summary>
482 /// <param name="data"></param> 482 /// <param name="data"></param>
483 /// <returns></returns> 483 /// <returns></returns>
484
484 public static string Md5Hash(string data) 485 public static string Md5Hash(string data)
485 { 486 {
486 byte[] dataMd5 = ComputeMD5Hash(data); 487 return Md5Hash(data, Encoding.Default);
488 }
489
490 public static string Md5Hash(string data, Encoding encoding)
491 {
492 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
487 StringBuilder sb = new StringBuilder(); 493 StringBuilder sb = new StringBuilder();
488 for (int i = 0; i < dataMd5.Length; i++) 494 for (int i = 0; i < dataMd5.Length; i++)
489 sb.AppendFormat("{0:x2}", dataMd5[i]); 495 sb.AppendFormat("{0:x2}", dataMd5[i]);
490 return sb.ToString(); 496 return sb.ToString();
491 } 497 }
492 498
493 private static byte[] ComputeMD5Hash(string data) 499 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
494 { 500 {
495 MD5 md5 = MD5.Create(); 501 MD5 md5 = MD5.Create();
496 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 502 return md5.ComputeHash(encoding.GetBytes(data));
497 } 503 }
498 504
499 /// <summary> 505 /// <summary>
@@ -501,6 +507,12 @@ namespace OpenSim.Framework
501 /// </summary> 507 /// </summary>
502 /// <param name="data"></param> 508 /// <param name="data"></param>
503 /// <returns></returns> 509 /// <returns></returns>
510
511 public static string SHA1Hash(string data, Encoding enc)
512 {
513 return SHA1Hash(enc.GetBytes(data));
514 }
515
504 public static string SHA1Hash(string data) 516 public static string SHA1Hash(string data)
505 { 517 {
506 return SHA1Hash(Encoding.Default.GetBytes(data)); 518 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -1156,19 +1168,19 @@ namespace OpenSim.Framework
1156 { 1168 {
1157 string os = String.Empty; 1169 string os = String.Empty;
1158 1170
1159 if (Environment.OSVersion.Platform != PlatformID.Unix) 1171// if (Environment.OSVersion.Platform != PlatformID.Unix)
1160 { 1172// {
1161 os = Environment.OSVersion.ToString(); 1173// os = Environment.OSVersion.ToString();
1162 } 1174// }
1163 else 1175// else
1164 { 1176// {
1165 os = ReadEtcIssue(); 1177// os = ReadEtcIssue();
1166 } 1178// }
1167 1179//
1168 if (os.Length > 45) 1180// if (os.Length > 45)
1169 { 1181// {
1170 os = os.Substring(0, 45); 1182// os = os.Substring(0, 45);
1171 } 1183// }
1172 1184
1173 return os; 1185 return os;
1174 } 1186 }
@@ -1300,7 +1312,7 @@ namespace OpenSim.Framework
1300 1312
1301 public static Guid GetHashGuid(string data, string salt) 1313 public static Guid GetHashGuid(string data, string salt)
1302 { 1314 {
1303 byte[] hash = ComputeMD5Hash(data + salt); 1315 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1304 1316
1305 //string s = BitConverter.ToString(hash); 1317 //string s = BitConverter.ToString(hash);
1306 1318