diff options
Diffstat (limited to 'main.sts')
-rw-r--r-- | main.sts | 45 |
1 files changed, 26 insertions, 19 deletions
@@ -1,30 +1,37 @@ module ia32/elf/begin.sts module cipher.sts -defarr bigbad 64000 ; max size of input is 64 000 chars -defarr bigbadres 64000 ; max size of output is 64 000 chars -defarr passwd 3 - set_entry - 31 passwd ! - 32 passwd 1 + ! - 33 passwd 2 + ! + ; read file into stack + 0 do sys_read 0 = until + swap 1 + + od as length + local ciphertext - 0 local bigbadlen - do sys_read 0 = until - over bigbad + ! - 1 + - od + ; -= MAIN LOOP BEGIN =- ; + ; place password ontop of stack + 33 32 31 local password + 3 as passlen - 0 local cipherpos - 0 do dup bigbadlen @ = until - dup bigbad + @ passwd 3 cipherpos cipher - over bigbadres + ! + ; decipher text (length is the same as for ciphertext) + 0 0 do dup length = until + as pos local cipos + pos ciphertext + @ + password + passlen + cipos + cipher + swap pos 1 + od drop drop + local plaintext - 0 do dup bigbadlen @ = until - dup bigbadres + @ sys_write - 1 + od drop drop + ; todo: check deciphering attempt, exit if Ok + ; -= MAIN LOOP END =- ; + + ; output text (todo: and language) + 0 do dup length = until + dup plaintext + @ sys_write + 1 + od sys_exit module ia32/elf/end.sts |