mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
Lua更新
This commit is contained in:
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace CMLeonOS
|
||||
{
|
||||
internal class Sha256
|
||||
public class Sha256
|
||||
{
|
||||
private static readonly uint[] K = new uint[64] {
|
||||
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace UniLua
|
||||
new NameFuncPair("clear", OS_Clear),
|
||||
new NameFuncPair("getusername", OS_Getusername),
|
||||
new NameFuncPair("isadmin", OS_Isadmin),
|
||||
new NameFuncPair("sha256", OS_Sha256),
|
||||
new NameFuncPair("base64encrypt", OS_Base64Encrypt),
|
||||
new NameFuncPair("base64decrypt", OS_Base64Decrypt),
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -177,6 +180,30 @@ namespace UniLua
|
||||
lua.PushBoolean(isAdmin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int OS_Sha256( ILuaState lua )
|
||||
{
|
||||
string input = lua.L_CheckString(1);
|
||||
string hash = CMLeonOS.UserSystem.HashPasswordSha256(input) ?? "";
|
||||
lua.PushString(hash);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int OS_Base64Encrypt( ILuaState lua )
|
||||
{
|
||||
string input = lua.L_CheckString(1);
|
||||
string encoded = CMLeonOS.Base64Helper.Encode(input);
|
||||
lua.PushString(encoded);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int OS_Base64Decrypt( ILuaState lua )
|
||||
{
|
||||
string input = lua.L_CheckString(1);
|
||||
string decoded = CMLeonOS.Base64Helper.Decode(input);
|
||||
lua.PushString(decoded);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace CMLeonOS
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
internal static string HashPasswordSha256(string password)
|
||||
public static string HashPasswordSha256(string password)
|
||||
{
|
||||
Sha256 sha256 = new Sha256();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user