moved fileio stuff to new file

This commit is contained in:
sa 2022-12-30 02:05:56 -05:00
parent 3e8b21fb6d
commit cec7feb2f8
2 changed files with 48 additions and 50 deletions

View File

@ -34,56 +34,6 @@ L = K
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
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 = input:read(block)
if byte == nil then
break
else
--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
input:close()
output:close()
]]
local S = {}
S[0] = P --initialize the S array
for i = 1, t do

48
src/fileIOtesting.lua Normal file
View File

@ -0,0 +1,48 @@
--[[
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
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 = input:read(block)
if byte == nil then
break
else
--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
input:close()
output:close()
]]