created and populated S array
This commit is contained in:
parent
98537f77d4
commit
a2b900c990
41
encrypt.lua
41
encrypt.lua
@ -17,10 +17,7 @@ c=length of key in words
|
||||
|
||||
local inspect = require 'inspect'
|
||||
|
||||
local insert
|
||||
local concat
|
||||
local tostring
|
||||
local modf
|
||||
local insert, concat, modf, tostring, char = table.insert, table.concat, math.modf, tostring, string.char
|
||||
|
||||
local w=64
|
||||
local r=24
|
||||
@ -29,6 +26,7 @@ local key="globglogabgalab1"
|
||||
local u=8 --length of a word in bytes
|
||||
--local c=2 (with globglogabgalab1 as the key c should =2)
|
||||
local L = {}
|
||||
local t = 2 * (r + 1) --the number of round subkeys required
|
||||
|
||||
--magic constants for 64bit word size (hex)
|
||||
local P = 0xb7e151628aed2a6b
|
||||
@ -41,30 +39,17 @@ print(c)
|
||||
|
||||
--convert the key into an array of ints
|
||||
local K = {string.byte(key, 1, -1)}
|
||||
for i = 1, #K do
|
||||
print(K[i])
|
||||
end
|
||||
|
||||
--for i = b-1, down to 0
|
||||
--becuse lua starts tables at 1 this is changed to
|
||||
L[c] = 0
|
||||
for i = b, 1, -1 do
|
||||
if L[i/u] == nil then
|
||||
L[i/u] = 0
|
||||
end
|
||||
L[i/u] = (L[i/u] << 8) + K[i]
|
||||
print(i)
|
||||
end
|
||||
|
||||
print(inspect(K))
|
||||
L = K
|
||||
print(inspect(L))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local S = {}
|
||||
S[0] = P
|
||||
S[1] = 1
|
||||
print(t)
|
||||
for i = 1, t - 1 do
|
||||
S[i] = S[i-1] + Q
|
||||
print(S[i])
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user