preliminary Clustered Virtual Disk; hardware dev kit wip

This commit is contained in:
minjaesong
2023-06-06 21:50:43 +09:00
parent f47d446ff0
commit 53ec998f26
18 changed files with 89 additions and 2587 deletions

View File

@@ -0,0 +1,9 @@
if (exec_args[1] === undefined) {
println("Usage: compile myfile")
println("The compiled file will be myfile.bin")
return 1
}
_G.shell.execute(`gzip -c ${exec_args[1]} | writeto ${exec_args[1]}.gz`)
_G.shell.execute(`enc ${exec_args[1]}.gz ${exec_args[1]}.bin`)
_G.shell.execute(`rm ${exec_args[1]}.gz`)

View File

@@ -0,0 +1,9 @@
if (exec_args[1] === undefined) {
println("Usage: decompile myfile.bin")
println("The compiled file will be myfile.bin.js")
return 1
}
_G.shell.execute(`enc ${exec_args[1]} ${exec_args[1]}.gz`)
_G.shell.execute(`gzip -c -d ${exec_args[1]}.gz | writeto ${exec_args[1]}.js`)
_G.shell.execute(`rm ${exec_args[1]}.gz`)

View File

@@ -0,0 +1,46 @@
function seq(s) {
let out = ""
let cnt = 0
let oldchar = s[0]
for (let char of s) {
if (char === oldchar) {
cnt += 1
}
else {
out += ('' + cnt) + oldchar
cnt = 1
}
oldchar = char
}
return out + cnt + oldchar
}
let infile = files.open(_G.shell.resolvePathInput(exec_args[1]).full)
let outfile = files.open(_G.shell.resolvePathInput(exec_args[2]).full)
let inBytes = infile.bread(); infile.close()
let outBytes = new Int8Array(inBytes.length)
let key = "00"
let keyBytes = [0x00]
let keyCursor = 0
function getNewKeySeq() {
key = seq(key)
keyBytes = []
keyCursor = 0
for (let i = 0; i < key.length; i += 2) {
keyBytes.push(parseInt(key.substring(i, i+2), 16))
}
}
for (let outcnt = 0; outcnt < inBytes.length; outcnt++) {
outBytes[outcnt] = inBytes[outcnt] ^ keyBytes[keyCursor++]
if (keyCursor >= keyBytes.length) {
getNewKeySeq()
}
}
outfile.bwrite(outBytes)

View File

@@ -0,0 +1,8 @@
TSVM Hardware Development Kit
Codes in the new computer hardware (e.g. EEPROM) are decrypted, decompressed
then executed, so your program must be minified, compressed, then encrypted to
be runnable, and this entire process is called "compiling".
Do note that this 'encryption' is highly insecure; its only purpose is to deter
the casual attemps at cracking.