diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index f511494..c049247 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -488,19 +488,25 @@ namespace OpenSim.Framework | |||
488 | /// </summary> | 488 | /// </summary> |
489 | /// <param name="data"></param> | 489 | /// <param name="data"></param> |
490 | /// <returns></returns> | 490 | /// <returns></returns> |
491 | |||
491 | public static string Md5Hash(string data) | 492 | public static string Md5Hash(string data) |
492 | { | 493 | { |
493 | byte[] dataMd5 = ComputeMD5Hash(data); | 494 | return Md5Hash(data, Encoding.Default); |
495 | } | ||
496 | |||
497 | public static string Md5Hash(string data, Encoding encoding) | ||
498 | { | ||
499 | byte[] dataMd5 = ComputeMD5Hash(data, encoding); | ||
494 | StringBuilder sb = new StringBuilder(); | 500 | StringBuilder sb = new StringBuilder(); |
495 | for (int i = 0; i < dataMd5.Length; i++) | 501 | for (int i = 0; i < dataMd5.Length; i++) |
496 | sb.AppendFormat("{0:x2}", dataMd5[i]); | 502 | sb.AppendFormat("{0:x2}", dataMd5[i]); |
497 | return sb.ToString(); | 503 | return sb.ToString(); |
498 | } | 504 | } |
499 | 505 | ||
500 | private static byte[] ComputeMD5Hash(string data) | 506 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
501 | { | 507 | { |
502 | MD5 md5 = MD5.Create(); | 508 | MD5 md5 = MD5.Create(); |
503 | return md5.ComputeHash(Encoding.Default.GetBytes(data)); | 509 | return md5.ComputeHash(encoding.GetBytes(data)); |
504 | } | 510 | } |
505 | 511 | ||
506 | /// <summary> | 512 | /// <summary> |
@@ -508,6 +514,12 @@ namespace OpenSim.Framework | |||
508 | /// </summary> | 514 | /// </summary> |
509 | /// <param name="data"></param> | 515 | /// <param name="data"></param> |
510 | /// <returns></returns> | 516 | /// <returns></returns> |
517 | |||
518 | public static string SHA1Hash(string data, Encoding enc) | ||
519 | { | ||
520 | return SHA1Hash(enc.GetBytes(data)); | ||
521 | } | ||
522 | |||
511 | public static string SHA1Hash(string data) | 523 | public static string SHA1Hash(string data) |
512 | { | 524 | { |
513 | return SHA1Hash(Encoding.Default.GetBytes(data)); | 525 | return SHA1Hash(Encoding.Default.GetBytes(data)); |
@@ -1163,19 +1175,19 @@ namespace OpenSim.Framework | |||
1163 | { | 1175 | { |
1164 | string os = String.Empty; | 1176 | string os = String.Empty; |
1165 | 1177 | ||
1166 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 1178 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
1167 | { | 1179 | // { |
1168 | os = Environment.OSVersion.ToString(); | 1180 | // os = Environment.OSVersion.ToString(); |
1169 | } | 1181 | // } |
1170 | else | 1182 | // else |
1171 | { | 1183 | // { |
1172 | os = ReadEtcIssue(); | 1184 | // os = ReadEtcIssue(); |
1173 | } | 1185 | // } |
1174 | 1186 | // | |
1175 | if (os.Length > 45) | 1187 | // if (os.Length > 45) |
1176 | { | 1188 | // { |
1177 | os = os.Substring(0, 45); | 1189 | // os = os.Substring(0, 45); |
1178 | } | 1190 | // } |
1179 | 1191 | ||
1180 | return os; | 1192 | return os; |
1181 | } | 1193 | } |
@@ -1307,7 +1319,7 @@ namespace OpenSim.Framework | |||
1307 | 1319 | ||
1308 | public static Guid GetHashGuid(string data, string salt) | 1320 | public static Guid GetHashGuid(string data, string salt) |
1309 | { | 1321 | { |
1310 | byte[] hash = ComputeMD5Hash(data + salt); | 1322 | byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); |
1311 | 1323 | ||
1312 | //string s = BitConverter.ToString(hash); | 1324 | //string s = BitConverter.ToString(hash); |
1313 | 1325 | ||