Uploaded by hibaobaidat11

Pseudo code

advertisement
Pseudo code:
SBoxs = [] [] [] //[number of sbox][row][column] //generate 10 different Sboxes
Function main()
masterKey = "0111000010001101101001111111011111010100"
plainText = "11001100"
Function encrypt(plaintext, key)
Subkeys[] //generate 5 subkeys
temp_out  plainText
For loop:
Set i for 0
Break when I reaches 4
Increment i by 1
sBoxOut  sBox(subKeys[i], temp_out)
pBoxOut  permitation(sBoxOut, i)
xorOut  xor(pBoxOut, subKeys[i])
temp_out = xorOut
return temp_out
Function sBox(subkey, plaintext) //convert binary to decimal
key  integer subkey mod 10
rev  reverse subkey
revkey  rev mod 10
finalString  SBoxes [key][r1][c1] + SBoxes[key][r2][c2]
return finalString
Function permutation(text, round)
chars []  text splitted by “ “
pTable [][] //generates a permutation table
For loop: set i to 0
break when i reaches 5 rounds
increment i by 1
s = s + chars[pTable[round][i]-1]
return s after shuffling
Function xor(text, subkey)
For loop: set i to 0
break when i reaches the text length
increment i by 1
IF text == subkey
s = s + ‘0’
ELSE
s = s + ‘1’
return s
Function reverseString(a)
For loop: set i to greater than or equal 0
break when i reaches the a length
decrement i by 1
s = s + a.charAt(i)
return s
Download