added a new function string=osSHA256(string)

Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
This commit is contained in:
Mike Higgins
2020-12-29 00:37:35 -08:00
committed by UbitUmarov
parent 5361045641
commit 0da43a8ef5
3 changed files with 28 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Security.Cryptography;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
@@ -2606,6 +2607,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return retval;
}
public string osSHA256(string input)
{
// Create a SHA256
using (SHA256 sha256Hash = SHA256.Create())
{
// ComputeHash - returns byte array
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
// Convert byte array to a string
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}
/// <summary>
/// Get the nickname of this grid, as set in the [GridInfo] config section.
/// </summary>
@@ -5999,4 +6020,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return 1;
}
}
}
}