Lua更新

This commit is contained in:
2026-02-04 02:36:07 +08:00
parent 5a07c7a133
commit 0020d125c7
4 changed files with 1257 additions and 2 deletions

1228
Lua.md Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -38,7 +38,7 @@ namespace CMLeonOS
Console.ResetColor();
}
internal static string HashPasswordSha256(string password)
public static string HashPasswordSha256(string password)
{
Sha256 sha256 = new Sha256();