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 1b9777f..a26e930 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));
@@ -1143,19 +1155,19 @@ namespace OpenSim.Framework
1143 { 1155 {
1144 string os = String.Empty; 1156 string os = String.Empty;
1145 1157
1146 if (Environment.OSVersion.Platform != PlatformID.Unix) 1158// if (Environment.OSVersion.Platform != PlatformID.Unix)
1147 { 1159// {
1148 os = Environment.OSVersion.ToString(); 1160// os = Environment.OSVersion.ToString();
1149 } 1161// }
1150 else 1162// else
1151 { 1163// {
1152 os = ReadEtcIssue(); 1164// os = ReadEtcIssue();
1153 } 1165// }
1154 1166//
1155 if (os.Length > 45) 1167// if (os.Length > 45)
1156 { 1168// {
1157 os = os.Substring(0, 45); 1169// os = os.Substring(0, 45);
1158 } 1170// }
1159 1171
1160 return os; 1172 return os;
1161 } 1173 }
@@ -1287,7 +1299,7 @@ namespace OpenSim.Framework
1287 1299
1288 public static Guid GetHashGuid(string data, string salt) 1300 public static Guid GetHashGuid(string data, string salt)
1289 { 1301 {
1290 byte[] hash = ComputeMD5Hash(data + salt); 1302 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1291 1303
1292 //string s = BitConverter.ToString(hash); 1304 //string s = BitConverter.ToString(hash);
1293 1305