worked on file io

This commit is contained in:
sa 2022-03-28 21:30:12 -04:00
parent 0064eb7d26
commit 8eb8a65d1c

View File

@ -20,7 +20,6 @@ local insert, concat, modf, tostring, char = table.insert, table.concat, math.mo
local w=64 --length of a word in bits
local u=8 --length of a word in bytes
local r=24
--local key="globglogabgalab1"
local key="0000000000000000"
local b=16 --length of the key in bytes
--local c=2 (with globglogabgalab1 as the key c should =2)
@ -31,11 +30,32 @@ local L = {}
--length of the key in words
c = math.ceil(math.max(b, 1) / u)
L = K
--magic constants for 64bit word size (hex)
local P = 0xb7e151628aed2a6b
local Q = 0x9e3779b97f4a7c15
--[[
main loop
read in file in 1 block bytes
this will work for files under 1MB for larger files
once the table reaches 512kb, encrypt it, and put it
into tmp files. once all of the data has been encrypted
stitch together all the tmp files
local bytes = {}
file = assert(io.open(arg[1], "rb"))
block = 1 --blocks of 1 byte
while true do
local byte = file:read(block)
if byte == nil then
break
else
bytes[#bytes+1] = string.byte(byte)
end
end
file:close()
]]
local S = {}
S[0] = P --initialize the S array
for i = 1, t do