mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 06:54:04 +09:00
preliminary Clustered Virtual Disk; hardware dev kit wip
This commit is contained in:
9
assets/disk0/home/hdk/compile.js
Normal file
9
assets/disk0/home/hdk/compile.js
Normal 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`)
|
||||
9
assets/disk0/home/hdk/decompile.js
Normal file
9
assets/disk0/home/hdk/decompile.js
Normal 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`)
|
||||
46
assets/disk0/home/hdk/enc.js
Normal file
46
assets/disk0/home/hdk/enc.js
Normal 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)
|
||||
8
assets/disk0/home/hdk/what_does_this.do
Normal file
8
assets/disk0/home/hdk/what_does_this.do
Normal 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.
|
||||
Reference in New Issue
Block a user