start implementing in ts

This commit is contained in:
DavidVentura
2024-01-25 00:09:57 +01:00
parent 65d033b82d
commit 094ffc0914
2 changed files with 41 additions and 6 deletions
+17
View File
@@ -0,0 +1,17 @@
import "./shim.ts";
const str2byte = (s: string): number[] => {
return Array.from(s).map((_, i) => s.charCodeAt(i));
};
const SendUsrChk = (username: string, password: string): DataView => {
// type is char account[0x20]; char password[0x80];
let buf = new Uint8Array(0x20 + 0x80);
buf.fill(0);
let cmd_payload = new DataView(buf.buffer);
cmd_payload.writeByteArray(str2byte(username));
cmd_payload.add(0x20).writeByteArray(str2byte(password));
return cmd_payload;
};
console.log(SendUsrChk("admin", "admin"));