worked on file io
This commit is contained in:
parent
8eb8a65d1c
commit
3e8b21fb6d
@ -42,20 +42,48 @@ 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
|
||||
load the file into two arrays as words into bytesA and bytesB
|
||||
where bytesA & B alternate between bytes (odd and even)
|
||||
|
||||
encrypt
|
||||
|
||||
merge arrays load into encrypted array
|
||||
|
||||
write to output file
|
||||
|
||||
local bytesA = {}
|
||||
local bytesB = {}
|
||||
input = assert(io.open(arg[1], "rb"))
|
||||
output = assert(io.open(arg[2], "wb"))
|
||||
io.output(arg[2])
|
||||
|
||||
local block = 1 --blocks of 1 byte
|
||||
while true do
|
||||
local byte = file:read(block)
|
||||
local byte = input:read(block)
|
||||
if byte == nil then
|
||||
break
|
||||
else
|
||||
bytes[#bytes+1] = string.byte(byte)
|
||||
--break word 1 into bytes
|
||||
--load the bytes into an array
|
||||
bytesA[#bytesA+1] = string.byte(byte)
|
||||
end
|
||||
|
||||
while true do
|
||||
local byte = input:read(block)
|
||||
if byte == nil then
|
||||
break
|
||||
else
|
||||
--break word 2 into bytes
|
||||
--load the bytes into an array
|
||||
--bytesB[#bytesB+1] = string.byte(byte)
|
||||
end
|
||||
merge arrays bytesA and bytesB
|
||||
end
|
||||
file:close()
|
||||
input:close()
|
||||
output:close()
|
||||
]]
|
||||
|
||||
|
||||
local S = {}
|
||||
S[0] = P --initialize the S array
|
||||
for i = 1, t do
|
||||
|
Loading…
x
Reference in New Issue
Block a user