mirror of
https://github.com/opensim/opensim.git
synced 2026-07-31 22:05:36 +08:00
added a new function string=osSHA256(string)
Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,6 +283,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
|
||||
string osAvatarName2Key(string firstname, string lastname);
|
||||
string osKey2Name(string id);
|
||||
string osSHA256(string input);
|
||||
|
||||
// Grid Info Functions
|
||||
string osGetGridNick();
|
||||
|
||||
@@ -521,6 +521,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
return m_OSSL_Functions.osKey2Name(id);
|
||||
}
|
||||
|
||||
public string osSHA256(string input)
|
||||
{
|
||||
return m_OSSL_Functions.osSHA256(input);
|
||||
}
|
||||
|
||||
public string osGetGridNick()
|
||||
{
|
||||
return m_OSSL_Functions.osGetGridNick();
|
||||
|
||||
Reference in New Issue
Block a user