mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 12:25:42 +08:00
cosmetics
This commit is contained in:
@@ -324,10 +324,8 @@ namespace OpenSim.Framework.Console
|
||||
m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition);
|
||||
|
||||
int count = m_commandLine.Length + prompt.Length;
|
||||
char[] spaces = new char[count];
|
||||
for(int i = 0; i < spaces.Length; i++)
|
||||
spaces[i] = ' ';
|
||||
System.Console.Write(spaces);
|
||||
if(count > 0)
|
||||
System.Console.Write(new string(' ', count));
|
||||
|
||||
m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition);
|
||||
}
|
||||
@@ -444,11 +442,12 @@ namespace OpenSim.Framework.Console
|
||||
m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition);
|
||||
|
||||
int count = m_commandLine.Length + prompt.Length - text.Length;
|
||||
|
||||
WriteLocalText(text, level);
|
||||
for (int i = 0; i < count; ++i)
|
||||
System.Console.Write(" ");
|
||||
System.Console.WriteLine();
|
||||
if(count > 0)
|
||||
System.Console.WriteLine(new string(' ', count));
|
||||
else
|
||||
System.Console.WriteLine();
|
||||
|
||||
m_cursorYPosition = System.Console.CursorTop;
|
||||
Show();
|
||||
}
|
||||
|
||||
@@ -1230,31 +1230,66 @@ namespace OpenSim.Framework
|
||||
return (char)(b > 9 ? b + 0x37 : b + '0');
|
||||
}
|
||||
|
||||
public static string bytesToHexString(Span<byte> bytes, bool lowerCaps)
|
||||
public static unsafe string bytesToHexString(byte[] bytes, bool lowerCaps)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
Span<char> chars = stackalloc char[2 * bytes.Length];
|
||||
if (lowerCaps)
|
||||
return string.Create(2 * bytes.Length, bytes, (chars, bytes) =>
|
||||
{
|
||||
fixed (char* dstb = chars)
|
||||
fixed (byte* srcb = bytes)
|
||||
{
|
||||
char* dst = dstb;
|
||||
if (lowerCaps)
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = srcb[i];
|
||||
*dst++ = HighNibbleToHexByteCharLowcaps(b);
|
||||
*dst++ = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = srcb[i];
|
||||
*dst++ = HighNibbleToHexByteCharLowcaps(b);
|
||||
*dst++ = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static unsafe string bytesToLowcaseHexString(byte[] bytes)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
return string.Create(2 * bytes.Length, bytes, (chars, bytes) =>
|
||||
{
|
||||
fixed (char* dstb = chars)
|
||||
fixed (byte* srcb = bytes)
|
||||
{
|
||||
char* dst = dstb;
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = srcb[i];
|
||||
*dst++ = HighNibbleToHexByteCharLowcaps(b);
|
||||
*dst++ = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (int i = 0, j = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = bytes[i];
|
||||
chars[j++] = HighNibbleToHexByteCharLowcaps(b);
|
||||
chars[j++] = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0, j = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = bytes[i];
|
||||
chars[j++] = HighNibbleToHexByteCharHighcaps(b);
|
||||
chars[j++] = LowNibbleToHexByteCharHighcaps(b);
|
||||
}
|
||||
}
|
||||
return new string(chars);
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -8231,12 +8231,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public LSL_String llSHA256String(LSL_String input)
|
||||
{
|
||||
byte[] bytes;
|
||||
// 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);
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
// ComputeHash - returns byte array
|
||||
bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input.m_string));
|
||||
}
|
||||
return Util.bytesToLowcaseHexString(bytes);
|
||||
}
|
||||
|
||||
protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve)
|
||||
|
||||
@@ -2619,13 +2619,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public string osSHA256(string input)
|
||||
{
|
||||
byte[] bytes;
|
||||
// Create a SHA256
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
// ComputeHash - returns byte array
|
||||
Span<byte> bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input)).AsSpan();
|
||||
return Util.bytesToHexString(bytes, true);
|
||||
bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
|
||||
}
|
||||
return Util.bytesToLowcaseHexString(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user