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 c4fc643..1cbb53f 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -430,19 +430,25 @@ namespace OpenSim.Framework
430 /// </summary> 430 /// </summary>
431 /// <param name="data"></param> 431 /// <param name="data"></param>
432 /// <returns></returns> 432 /// <returns></returns>
433
433 public static string Md5Hash(string data) 434 public static string Md5Hash(string data)
434 { 435 {
435 byte[] dataMd5 = ComputeMD5Hash(data); 436 return Md5Hash(data, Encoding.Default);
437 }
438
439 public static string Md5Hash(string data, Encoding encoding)
440 {
441 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
436 StringBuilder sb = new StringBuilder(); 442 StringBuilder sb = new StringBuilder();
437 for (int i = 0; i < dataMd5.Length; i++) 443 for (int i = 0; i < dataMd5.Length; i++)
438 sb.AppendFormat("{0:x2}", dataMd5[i]); 444 sb.AppendFormat("{0:x2}", dataMd5[i]);
439 return sb.ToString(); 445 return sb.ToString();
440 } 446 }
441 447
442 private static byte[] ComputeMD5Hash(string data) 448 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
443 { 449 {
444 MD5 md5 = MD5.Create(); 450 MD5 md5 = MD5.Create();
445 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 451 return md5.ComputeHash(encoding.GetBytes(data));
446 } 452 }
447 453
448 /// <summary> 454 /// <summary>
@@ -450,6 +456,12 @@ namespace OpenSim.Framework
450 /// </summary> 456 /// </summary>
451 /// <param name="data"></param> 457 /// <param name="data"></param>
452 /// <returns></returns> 458 /// <returns></returns>
459
460 public static string SHA1Hash(string data, Encoding enc)
461 {
462 return SHA1Hash(enc.GetBytes(data));
463 }
464
453 public static string SHA1Hash(string data) 465 public static string SHA1Hash(string data)
454 { 466 {
455 return SHA1Hash(Encoding.Default.GetBytes(data)); 467 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -1054,19 +1066,19 @@ namespace OpenSim.Framework
1054 { 1066 {
1055 string os = String.Empty; 1067 string os = String.Empty;
1056 1068
1057 if (Environment.OSVersion.Platform != PlatformID.Unix) 1069// if (Environment.OSVersion.Platform != PlatformID.Unix)
1058 { 1070// {
1059 os = Environment.OSVersion.ToString(); 1071// os = Environment.OSVersion.ToString();
1060 } 1072// }
1061 else 1073// else
1062 { 1074// {
1063 os = ReadEtcIssue(); 1075// os = ReadEtcIssue();
1064 } 1076// }
1065 1077//
1066 if (os.Length > 45) 1078// if (os.Length > 45)
1067 { 1079// {
1068 os = os.Substring(0, 45); 1080// os = os.Substring(0, 45);
1069 } 1081// }
1070 1082
1071 return os; 1083 return os;
1072 } 1084 }
@@ -1199,7 +1211,7 @@ namespace OpenSim.Framework
1199 1211
1200 public static Guid GetHashGuid(string data, string salt) 1212 public static Guid GetHashGuid(string data, string salt)
1201 { 1213 {
1202 byte[] hash = ComputeMD5Hash(data + salt); 1214 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1203 1215
1204 //string s = BitConverter.ToString(hash); 1216 //string s = BitConverter.ToString(hash);
1205 1217