added encryption algorithm

This commit is contained in:
sa 2022-03-28 13:57:55 -04:00
parent 3773e9b22f
commit f6897d446b

View File

@ -85,4 +85,17 @@ for f = 1, 3 * math.max(t,c) do
]]
end
--encrypt
--assume that the input block is given in two w-bit registers
--A and B
--the A and B found in the setup have been loaded into the S
--array and can now be filled with words of plaintext
A = A + S[1]
B = B + S[2]
for i = 1, r do
A = bit.rol((bit.bxor(A, B)), B) + S[2*i]
B = bit.rol((bit.bxor(B, A)), A) + S[2*i + 1]
end
print("Encrypted output A & B")
print(A)
print(B)