mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
add llSHA256String() same as osSHA256
This commit is contained in:
@@ -1230,12 +1230,12 @@ namespace OpenSim.Framework
|
||||
return (char)(b > 9 ? b + 0x37 : b + '0');
|
||||
}
|
||||
|
||||
public static string bytesToHexString(byte[] bytes, bool lowerCaps)
|
||||
public static string bytesToHexString(Span<byte> bytes, bool lowerCaps)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
char[] chars = new char[2 * bytes.Length];
|
||||
Span<char> chars = stackalloc char[2 * bytes.Length];
|
||||
if (lowerCaps)
|
||||
{
|
||||
for (int i = 0, j = 0; i < bytes.Length; ++i)
|
||||
|
||||
@@ -52,6 +52,7 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
@@ -8228,6 +8229,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return Util.SHA1Hash(src, Encoding.UTF8).ToLower();
|
||||
}
|
||||
|
||||
public LSL_String llSHA256String(LSL_String input)
|
||||
{
|
||||
// Create a SHA256
|
||||
using SHA256 sha256Hash = SHA256.Create();
|
||||
|
||||
// ComputeHash - returns byte array
|
||||
Span<byte> bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input)).AsSpan();
|
||||
return Util.bytesToHexString(bytes, true);
|
||||
}
|
||||
|
||||
protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve)
|
||||
{
|
||||
float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
|
||||
|
||||
@@ -2623,7 +2623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
// ComputeHash - returns byte array
|
||||
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
|
||||
Span<byte> bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input)).AsSpan();
|
||||
return Util.bytesToHexString(bytes, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llMapDestination(string simname, LSL_Vector pos, LSL_Vector look_at);
|
||||
LSL_String llMD5String(string src, int nonce);
|
||||
LSL_String llSHA1String(string src);
|
||||
LSL_String llSHA256String(LSL_String src);
|
||||
void llMessageLinked(int linknum, int num, string str, string id);
|
||||
void llMinEventDelay(double delay);
|
||||
void llModifyLand(int action, int brush);
|
||||
|
||||
@@ -1157,6 +1157,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
return m_LSL_Functions.llSHA1String(src);
|
||||
}
|
||||
|
||||
public LSL_String llSHA256String(LSL_String src)
|
||||
{
|
||||
return m_LSL_Functions.llSHA256String(src);
|
||||
}
|
||||
|
||||
public void llMessageLinked(int linknum, int num, string str, string id)
|
||||
{
|
||||
m_LSL_Functions.llMessageLinked(linknum, num, str, id);
|
||||
|
||||
Reference in New Issue
Block a user