Posted 07 July 2012 - 12:56 PM
Hey there.
I got bored and decided to make a cryptography program.
I get error bit:40: number expected, got string. What do I convert to number?
Can't figure it out o.O
I got bored and decided to make a cryptography program.
I get error bit:40: number expected, got string. What do I convert to number?
-- Jazza's Ecryption - V.0.0.1 - Jazza_Hat
os.pullEvent = os.pullEventRaw
print("Please enter a password. It can be a maximum of 16 characters")
pass = read("*")
bpass = bit.tobits(pass)
plen = string.len(pass)
key = math.random(128,255)
bkey = bit.tobits(key)
passxorkey1 = string.sub(bpass, 1, 8)
passxorkey2 = string.sub(bpass, 9, 16)
passxorkey3 = string.sub(bpass, 17, 24)
passxorkey4 = string.sub(bpass, 25, 32)
passxorkey5 = string.sub(bpass, 33, 40)
passxorkey6 = string.sub(bpass, 41, 48)
passxorkey7 = string.sub(bpass, 49, 56)
passxorkey8 = string.sub(bpass, 57, 64)
passxorkey9 = string.sub(bpass, 65, 72)
passxorkey10 = string.sub(bpass, 73, 80)
passxorkey11 = string.sub(bpass, 81, 88)
passxorkey12 = string.sub(bpass, 89, 96)
passxorkey13 = string.sub(bpass, 97, 104)
passxorkey14 = string.sub(bpass, 105, 112)
passxorkey15 = string.sub(bpass, 113, 120)
passxorkey16 = string.sub(bpass, 121, 128)
for i = 0, plen, 1 do
fpass[i] = bit.bxor(passxorkey[i],bkey)
end
filev = fs.open("pass.enc", w)
h.write(fpass[1],fpass[2],fpass[3],fpass[4],fpass[5],fpass[6],fpass[7],fpass[8],fpass[9],fpass[10],fpass[11],fpass[12],fpass[13],fpass[14],fpass[15],fpass[16])
h.close()
Can't figure it out o.O