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