add llSHA256String() same as osSHA256

This commit is contained in:
UbitUmarov
2022-10-22 14:10:07 +01:00
parent 0d35531200
commit a28c875ce4
5 changed files with 20 additions and 3 deletions

View File

@@ -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.

View File

@@ -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);
}
}