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 9b1e97d..e0d4d74 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -500,19 +500,25 @@ namespace OpenSim.Framework
500 /// </summary> 500 /// </summary>
501 /// <param name="data"></param> 501 /// <param name="data"></param>
502 /// <returns></returns> 502 /// <returns></returns>
503
503 public static string Md5Hash(string data) 504 public static string Md5Hash(string data)
504 { 505 {
505 byte[] dataMd5 = ComputeMD5Hash(data); 506 return Md5Hash(data, Encoding.Default);
507 }
508
509 public static string Md5Hash(string data, Encoding encoding)
510 {
511 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
506 StringBuilder sb = new StringBuilder(); 512 StringBuilder sb = new StringBuilder();
507 for (int i = 0; i < dataMd5.Length; i++) 513 for (int i = 0; i < dataMd5.Length; i++)
508 sb.AppendFormat("{0:x2}", dataMd5[i]); 514 sb.AppendFormat("{0:x2}", dataMd5[i]);
509 return sb.ToString(); 515 return sb.ToString();
510 } 516 }
511 517
512 private static byte[] ComputeMD5Hash(string data) 518 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
513 { 519 {
514 MD5 md5 = MD5.Create(); 520 MD5 md5 = MD5.Create();
515 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 521 return md5.ComputeHash(encoding.GetBytes(data));
516 } 522 }
517 523
518 /// <summary> 524 /// <summary>
@@ -520,6 +526,12 @@ namespace OpenSim.Framework
520 /// </summary> 526 /// </summary>
521 /// <param name="data"></param> 527 /// <param name="data"></param>
522 /// <returns></returns> 528 /// <returns></returns>
529
530 public static string SHA1Hash(string data, Encoding enc)
531 {
532 return SHA1Hash(enc.GetBytes(data));
533 }
534
523 public static string SHA1Hash(string data) 535 public static string SHA1Hash(string data)
524 { 536 {
525 return SHA1Hash(Encoding.Default.GetBytes(data)); 537 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -1175,19 +1187,19 @@ namespace OpenSim.Framework
1175 { 1187 {
1176 string os = String.Empty; 1188 string os = String.Empty;
1177 1189
1178 if (Environment.OSVersion.Platform != PlatformID.Unix) 1190// if (Environment.OSVersion.Platform != PlatformID.Unix)
1179 { 1191// {
1180 os = Environment.OSVersion.ToString(); 1192// os = Environment.OSVersion.ToString();
1181 } 1193// }
1182 else 1194// else
1183 { 1195// {
1184 os = ReadEtcIssue(); 1196// os = ReadEtcIssue();
1185 } 1197// }
1186 1198//
1187 if (os.Length > 45) 1199// if (os.Length > 45)
1188 { 1200// {
1189 os = os.Substring(0, 45); 1201// os = os.Substring(0, 45);
1190 } 1202// }
1191 1203
1192 return os; 1204 return os;
1193 } 1205 }
@@ -1319,7 +1331,7 @@ namespace OpenSim.Framework
1319 1331
1320 public static Guid GetHashGuid(string data, string salt) 1332 public static Guid GetHashGuid(string data, string salt)
1321 { 1333 {
1322 byte[] hash = ComputeMD5Hash(data + salt); 1334 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1323 1335
1324 //string s = BitConverter.ToString(hash); 1336 //string s = BitConverter.ToString(hash);
1325 1337