Friday, August 14, 2009

Auto Key Options

If it is english in alphabet so, Z_{26}....mod 26
0 <= k <=25

formula:- first number a_{1} = x_{1} + k.........where x is
plaintext, k is your auto key
consequences a_{i} = x_{i-1} , i >= 2


encryption: e(x_{1}) = x_{1} + k...........for 1st one character
decryption: d(y_{1}) = y_{1} - k ...........for 1st one character


decryption ( is minus)
Example: k = 8
Ciphertext is: B H R D Y ...............y
1 7 17 3 24


start to solve:

step 1:
Keystream : 8 .........k,
always put the k value in the 1st place

step 2:
Plaintext : d(y_{1}) = y_{1} - k
d(1) = 1 - 8 = -7 mod 26 = 26 - 7 =19 mod 26
so...P : 19

step 3:
Keystream : 8 19 ......always put the previous ans for the following keystream

repeate step 2:
Plaintext : d(7) = 7 - 19 = 14 mod 26

repeate step 3:
Keystream : 8 19 14 ......always put the previous ans for the following keystream

repeate step 2:
Plaintext : d(17) = 17 - 14 = 3mod 26

repeate step 3:
Keystream : 8 19 14 3 ......always put the previous ans for the following keystream

repeate step 2:
Plaintext : d(3) = 3- 3 = 0 mod 26

repeate step 3:
Keystream : 8 19 14 3 0 ......always put the previous ans for the following keystream

repeate step 2:
Plaintext : d(24) = 24 - 0= 24mod 26

repeate step 3:
Keystream : 8 19 14 3 0 24

......finally we have
Ciphertext is: B H R D Y ...............y
1 7 17 3 24


Keystream : 8 19 14 3 0

Plaintext : 19 14 3 0 24
solved : T O D A Y

///////////encryption ( is plus) ////////////
Example: k = 8
Plaintext : T O D A Y .................x
code : 19 14 3 0 24

start to solve:
step 1:
Keystream : 8 .........k, always put the k value in the 1st place

step 2: .........here can directly put the key stream
Keystream : 8 19 14 3 0 ......put the key in ascending order

step 3:
Plaintext : e(x_{1}) = x_{1} + k
e(19) = 19 + 8 = 1 mod 26
so...Ciphertext : 1

repeat step 3:
Plaintext : e(x_{1}) = x_{1} + k
e(14) = 14 + 19 = 7 mod 26
so...Ciphertext : 1 7

repeat step 3:
Plaintext : e(x_{1}) = x_{1} + k
e(3) = 3 + 14= 17 mod 26
so...Ciphertext : 1 7 17

repeat step 3:
Plaintext : e(x_{1}) = x_{1} + k
e(0) = 0 + 3= 3 mod 26
so...Ciphertext : 1 7 17 3

repeat step 3:
Plaintext : e(x_{1}) = x_{1} + k
e(24) = 24 + 0= 24 mod 26
so...Ciphertext : 1 7 17 3 24


......finally we have
solved : T O D A Y.................x
code : 19 14 3 0 24
Keystream : 8 19 14 3 0
Ciphertext : 1 7 17 3 24

Ciphertext is : B H R D Y ...............y

No comments: