diff options
author | lbsa71 | 2009-03-31 05:51:28 +0000 |
---|---|---|
committer | lbsa71 | 2009-03-31 05:51:28 +0000 |
commit | fb9a358b797418fbc4c38dd9ec67e12bb5b7c98a (patch) | |
tree | 76d79c2b83945f40026e0dbb7558e909da173a43 /OpenSim/Framework/Util.cs | |
parent | Thanks rtomita for a patch to add a handler for the RemoveInventoryObjects pa... (diff) | |
download | opensim-SC-fb9a358b797418fbc4c38dd9ec67e12bb5b7c98a.zip opensim-SC-fb9a358b797418fbc4c38dd9ec67e12bb5b7c98a.tar.gz opensim-SC-fb9a358b797418fbc4c38dd9ec67e12bb5b7c98a.tar.bz2 opensim-SC-fb9a358b797418fbc4c38dd9ec67e12bb5b7c98a.tar.xz |
* Refactored out and de-duplicated Base64ToString(string)
* Fixed minor typo
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index ba19dc6..cce2adb 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -342,7 +342,7 @@ namespace OpenSim.Framework | |||
342 | /// <returns></returns> | 342 | /// <returns></returns> |
343 | public static string Md5Hash(string pass) | 343 | public static string Md5Hash(string pass) |
344 | { | 344 | { |
345 | MD5 md5 = MD5CryptoServiceProvider.Create(); | 345 | MD5 md5 = MD5.Create(); |
346 | byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass)); | 346 | byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass)); |
347 | StringBuilder sb = new StringBuilder(); | 347 | StringBuilder sb = new StringBuilder(); |
348 | for (int i = 0; i < dataMd5.Length; i++) | 348 | for (int i = 0; i < dataMd5.Length; i++) |
@@ -419,7 +419,7 @@ namespace OpenSim.Framework | |||
419 | output.Append(": "); | 419 | output.Append(": "); |
420 | } | 420 | } |
421 | 421 | ||
422 | output.Append(CleanString(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1))); | 422 | output.Append(CleanString(Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1))); |
423 | } | 423 | } |
424 | else | 424 | else |
425 | { | 425 | { |
@@ -532,7 +532,7 @@ namespace OpenSim.Framework | |||
532 | /// <returns>safe path</returns> | 532 | /// <returns>safe path</returns> |
533 | public static string safePath(string path) | 533 | public static string safePath(string path) |
534 | { | 534 | { |
535 | return Regex.Replace(path, @regexInvalidPathChars, string.Empty); | 535 | return Regex.Replace(path, regexInvalidPathChars, String.Empty); |
536 | } | 536 | } |
537 | 537 | ||
538 | /// <summary> | 538 | /// <summary> |
@@ -542,7 +542,7 @@ namespace OpenSim.Framework | |||
542 | /// <returns>safe filename</returns> | 542 | /// <returns>safe filename</returns> |
543 | public static string safeFileName(string filename) | 543 | public static string safeFileName(string filename) |
544 | { | 544 | { |
545 | return Regex.Replace(filename, @regexInvalidFileChars, string.Empty); | 545 | return Regex.Replace(filename, regexInvalidFileChars, String.Empty); |
546 | ; | 546 | ; |
547 | } | 547 | } |
548 | 548 | ||
@@ -594,7 +594,7 @@ namespace OpenSim.Framework | |||
594 | { | 594 | { |
595 | FileInfo f = new FileInfo(FileName); | 595 | FileInfo f = new FileInfo(FileName); |
596 | 596 | ||
597 | if (!string.IsNullOrEmpty(f.Extension)) | 597 | if (!String.IsNullOrEmpty(f.Extension)) |
598 | { | 598 | { |
599 | Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.')); | 599 | Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.')); |
600 | } | 600 | } |
@@ -959,7 +959,7 @@ namespace OpenSim.Framework | |||
959 | } | 959 | } |
960 | else if (fieldInfo.FieldType == typeof(System.UInt32)) | 960 | else if (fieldInfo.FieldType == typeof(System.UInt32)) |
961 | { | 961 | { |
962 | fieldInfo.SetValue(settingsClass, System.Convert.ToUInt32(config.Get(fieldInfo.Name, ((uint)fieldInfo.GetValue(settingsClass)).ToString()))); | 962 | fieldInfo.SetValue(settingsClass, Convert.ToUInt32(config.Get(fieldInfo.Name, ((uint)fieldInfo.GetValue(settingsClass)).ToString()))); |
963 | } | 963 | } |
964 | } | 964 | } |
965 | } | 965 | } |
@@ -987,12 +987,25 @@ namespace OpenSim.Framework | |||
987 | } | 987 | } |
988 | if (propInfo.PropertyType == typeof(System.UInt32)) | 988 | if (propInfo.PropertyType == typeof(System.UInt32)) |
989 | { | 989 | { |
990 | propInfo.SetValue(settingsClass, System.Convert.ToUInt32(config.Get(propInfo.Name, ((uint)propInfo.GetValue(settingsClass, null)).ToString())), null); | 990 | propInfo.SetValue(settingsClass, Convert.ToUInt32(config.Get(propInfo.Name, ((uint)propInfo.GetValue(settingsClass, null)).ToString())), null); |
991 | } | 991 | } |
992 | } | 992 | } |
993 | } | 993 | } |
994 | 994 | ||
995 | return settingsClass; | 995 | return settingsClass; |
996 | } | 996 | } |
997 | |||
998 | public static string Base64ToString(string str) | ||
999 | { | ||
1000 | UTF8Encoding encoder = new UTF8Encoding(); | ||
1001 | Decoder utf8Decode = encoder.GetDecoder(); | ||
1002 | |||
1003 | byte[] todecode_byte = Convert.FromBase64String(str); | ||
1004 | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); | ||
1005 | char[] decoded_char = new char[charCount]; | ||
1006 | utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); | ||
1007 | string result = new String(decoded_char); | ||
1008 | return result; | ||
1009 | } | ||
997 | } | 1010 | } |
998 | } | 1011 | } |