bin/crypto.lua
Ryan 7b4d0a23b2 Restructured some things!
Cleaned up files within the bin folder
Added:
+ bin:toDataBuffer()
[Converts a binobj to a data buffer]
+ bin:slide(n)
[changes the value of the characters by n, if n>255 it will wrap back around to 0]

Note: While streamable files can handle massive files without an issue, converting a massive file to a databuffer will probably throw a memory error!
2017-09-27 15:46:06 -04:00

38 lines
1004 B
Lua

package.path="?/init.lua;?.lua;"..package.path
require("multi")
require("bin")
--~ function bin.streamCipherEncrypt(data,key)
--~
--~ end
--~ t=bin.new("Hello")
--~ print(t)
--~ t:slide(50)
--~ print(t)
--~ t:slide(-50)
--~ print(t)
--~ t2=bin.stream("test.dat",false)
--~ tt=t2:toDataBuffer()
--~ print(tt[1])
print("TEST - 1")
test=bin.new("I am a string in a bin")
print(test)
print("TEST - 2: Writing a test file to disk")
test2=bin.freshStream("newFileToStreamWriteTo.dat",false)
test2:addBlock(1234,4)
test2:addBlock("Hello",5)
test2:addBlock(true) -- always 1 and a lua type
test2:addBlock({1,2,3,4,5}) -- depends and is a lua type
test2:close()
print("test 2 done")
print("TEST - 3: reading the file we wrote to disk")
test3=bin.load("newFileToStreamWriteTo.dat") -- binary file
nL,nB=test3:getBlock("n",4) -- reads the first 4 bytes as a number
-- litte endian, big endian
print(nL,nB)
str=test3:getBlock("s",5)
print(str)
bool=test3:getBlock("b")
print(bool)
tab=test3:getBlock("t")
print(tab)