diff options
author | Tom | 2011-01-26 12:54:12 -0800 |
---|---|---|
committer | Tom | 2011-01-26 12:54:12 -0800 |
commit | 04c62c4959d99ed3a8d350464db64aac6db1ec5f (patch) | |
tree | e238c4da8ea7beaf4159fa0f7c32a18718b89f72 /OpenSim | |
parent | Provide an SL compatible llMD5String function across all platforms (diff) | |
download | opensim-SC_OLD-04c62c4959d99ed3a8d350464db64aac6db1ec5f.zip opensim-SC_OLD-04c62c4959d99ed3a8d350464db64aac6db1ec5f.tar.gz opensim-SC_OLD-04c62c4959d99ed3a8d350464db64aac6db1ec5f.tar.bz2 opensim-SC_OLD-04c62c4959d99ed3a8d350464db64aac6db1ec5f.tar.xz |
Revert my previous SHA1 commit in favour of a better implementation
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 9227708..96292ff 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -435,16 +435,22 @@ namespace OpenSim.Framework | |||
435 | /// </summary> | 435 | /// </summary> |
436 | /// <param name="data"></param> | 436 | /// <param name="data"></param> |
437 | /// <returns></returns> | 437 | /// <returns></returns> |
438 | |||
438 | public static string SHA1Hash(string data) | 439 | public static string SHA1Hash(string data) |
439 | { | 440 | { |
440 | byte[] hash = ComputeSHA1Hash(data); | 441 | return SHA1Hash(data, Encoding.Default); |
442 | } | ||
443 | |||
444 | public static string SHA1Hash(string data, Encoding encoding) | ||
445 | { | ||
446 | byte[] hash = ComputeSHA1Hash(data, encoding); | ||
441 | return BitConverter.ToString(hash).Replace("-", String.Empty); | 447 | return BitConverter.ToString(hash).Replace("-", String.Empty); |
442 | } | 448 | } |
443 | 449 | ||
444 | private static byte[] ComputeSHA1Hash(string src) | 450 | private static byte[] ComputeSHA1Hash(string src, Encoding encoding) |
445 | { | 451 | { |
446 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); | 452 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); |
447 | return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); | 453 | return SHA1.ComputeHash(encoding.GetBytes(src)); |
448 | } | 454 | } |
449 | 455 | ||
450 | public static int fast_distance2d(int x, int y) | 456 | public static int fast_distance2d(int x, int y) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 45af13a..f5b7f5f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -32,7 +32,6 @@ using System.Diagnostics; //for [DebuggerNonUserCode] | |||
32 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Security.Cryptography; | ||
36 | using System.Text.RegularExpressions; | 35 | using System.Text.RegularExpressions; |
37 | using Nini.Config; | 36 | using Nini.Config; |
38 | using log4net; | 37 | using log4net; |
@@ -6945,8 +6944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6945 | public LSL_String llSHA1String(string src) | 6944 | public LSL_String llSHA1String(string src) |
6946 | { | 6945 | { |
6947 | m_host.AddScriptLPS(1); | 6946 | m_host.AddScriptLPS(1); |
6948 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); | 6947 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
6949 | return BitConverter.ToString(SHA1.ComputeHash(Encoding.UTF8.GetBytes(src))).Replace("-", String.Empty).ToLower(); | ||
6950 | } | 6948 | } |
6951 | 6949 | ||
6952 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6950 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |