### 新增IO 类

### 新增MD5 类

### 新增Mysql 类

### 新增Timer 类
This commit is contained in:
lenheart
2024-09-20 19:24:32 +08:00
parent 237bcf8719
commit 7f547f5fd4
21 changed files with 1234 additions and 16 deletions

View File

@@ -0,0 +1,42 @@
/*
文件名:MD5Class.nut
路径:Dps_A/BaseClass/MD5Class/MD5Class.nut
创建日期:2024-09-20 00:06
文件用途:MD5类
*/
class MD5 {
MD5_Init_ptr = Module.getExportByName(null, "MD5_Init");
MD5_Update_ptr = Module.getExportByName(null, "MD5_Update");
MD5_Final_ptr = Module.getExportByName(null, "MD5_Final");
function MD5_Init(Ctx) {
Sq_CallFunc(MD5_Init_ptr, "void", ["pointer"], Ctx);
}
function MD5_Update(Ctx, Buffer, Size) {
Sq_CallFunc(MD5_Update_ptr, "void", ["pointer", "pointer", "int"], Ctx, Buffer, Size);
}
function MD5_Final(Ctx, Result) {
Sq_CallFunc(MD5_Final_ptr, "void", ["pointer", "pointer"], Ctx, Result);
}
function GetFile(FileName) {
local Io = IO(FileName, "r+");
local Ctx = Memory.alloc(0x100);
MD5.MD5_Init(Ctx.C_Object);
while (true) {
local Buffer = Memory.alloc(0x1000);
local Res = Io.ReadBuffer(0x1000);
if (Res.count == 0) break;
MD5.MD5_Update(Ctx.C_Object, Memory.allocUtf8String(Res.str).C_Object, Res.count);
}
local Result = Memory.alloc(16);
MD5.MD5_Final(Result.C_Object, Ctx.C_Object);
Io.Close();
return Result.readUtf8String(16);
}
}