0% found this document useful (0 votes)
68 views3 pages

RC4 Encryption Explained

This document summarizes the RC4 symmetric cryptosystem. It describes generating a random permutation of bytes using a key, then using that permutation to encrypt and decrypt messages by XORing bytes of the message with bytes of the permutation. A sample message "Sysadmin" is encrypted to "eOEWR[_X" using this method and then decrypted back to the original text.

Uploaded by

Anton Andrian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views3 pages

RC4 Encryption Explained

This document summarizes the RC4 symmetric cryptosystem. It describes generating a random permutation of bytes using a key, then using that permutation to encrypt and decrypt messages by XORing bytes of the message with bytes of the permutation. A sample message "Sysadmin" is encrypted to "eOEWR[_X" using this method and then decrypted back to the original text.

Uploaded by

Anton Andrian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Criptosisteme simetrice fluide: RC4

n=3
23 =8 – flux de biţi
Formăm vectrul S: 01234567
Alegem cheia: 26, K – vectorul cheii
Codul ASCII al cheii este: 2 → 50; 6 → 54;
Vectorul cheii este:
50 54 50 54 50 54 50 54

Depunem valorile codului ASCII al cheii:


P 0 1 2 3 4 5 6 7
S 0 1 2 3 4 5 6 7
K 50 54 50 54 50 54 50 54

Efectuăm permutări asupra biţilor vectorului S:

Iniţial i=0, j=0.


j=(j+K[i]+S[j]) mod 8

1) i=0, j=(0+K[0]+S[0]) mod 8 = (0+50+0) mod 8 = 50 mod 8 = 2;


SWAP(S[i],S[j])=SWAP(S[0],S[2])=21034567= 50 54 50 54 50 54 50 54
P 0 1 2 3 4 5 6 7
S 2 1 0 3 4 5 6 7
K 50 54 50 54 50 54 50 54

2) i=1, j=(2+K[1]+S[1]) mod 8 = (2+54+1) mod 8 = 57 mod 8 = 1;


SWAP(S[i],S[j])=SWAP(S[1],S[1])= 21034567= 50 54 50 54 50 54 50 54
P 0 1 2 3 4 5 6 7
S 2 1 0 3 4 5 6 7
K 50 54 50 54 50 54 50 54

3) i=2, j=(1+K[2]+S[2]) mod 8 = (1+50+0) mod 8 = 51 mod 8 = 3;


SWAP(S[i],S[j])=SWAP(S[2],S[3])= 21304567= 50 54 54 50 50 54 50 54
P 0 1 2 3 4 5 6 7
S 2 1 3 0 4 5 6 7
K 50 54 54 50 50 54 50 54

4) i=3, j=(3+K[3]+S[3]) mod 8 = (3+50+0) mod 8 = 53 mod 8 = 5;


SWAP(S[i],S[j])=SWAP(S[3],S[5])= 21354067= 50 54 54 54 50 50 50 54
P 0 1 2 3 4 5 6 7
S 2 1 3 5 4 0 6 7
K 50 54 54 54 50 50 50 54

1
5) i=4, j=(5+K[4]+S[4]) mod 8 = (0+50+4) mod 8 = 54 mod 8 = 6;
SWAP(S[i],S[j])=SWAP(S[4],S[6])= 21356047= 50 54 54 54 50 50 50 54
P 0 1 2 3 4 5 6 7
S 2 1 3 5 6 0 4 7
K 50 54 54 54 50 50 50 54

6) i=5, j=(6+K[5]+S[5]) mod 8 = (5+50+0) mod 8 = 55 mod 8 = 7;


SWAP(S[i],S[j])=SWAP(S[5],S[7])= 21356740= 50 54 54 54 50 54 50 50
P 0 1 2 3 4 5 6 7
S 2 1 3 5 6 7 4 0
K 50 54 54 54 50 54 50 50

7) i=6, j=(7+K[6]+S[6]) mod 8 = (6+50+4) mod 8 = 60 mod 8 = 4;


SWAP(S[i],S[j])=SWAP(S[6],S[4])= 21354760= 50 54 54 54 50 54 50 50
P 0 1 2 3 4 5 6 7
S 2 1 3 5 4 7 6 0
K 50 54 54 54 50 54 50 50

8) i=7, j=(4+K[7]+S[7]) mod 8 = (7+50+0) mod 8 = 57 mod 8 = 1;


SWAP(S[i],S[j])=SWAP(S[7],S[1])= 20354761= 50 50 54 54 50 54 50 54
P 0 1 2 3 4 5 6 7
S 2 0 3 5 4 7 6 1
K 50 50 54 54 50 54 50 54

CRIPTARE

Alegem un mesaj pentru criptare m = Sysadmin


Iniţial i=0, j=0.
i=(i+1) mod 8 = 1 mod 8 = 1.
j=(j+S[i]) mod 8 = (j+S[1]) mod 8 = (0+0) mod 8 = 0

Calculam t:
t=(S[i]+S[j]) mod 8 = (S[1]+S[0]) mod 8 = (0+2) mod 8 = 2

Criptul r = chr(ord(m)) XOR K[t]

, K[t] = K[2] = (54)2 = (00110110)2


m[0] = S → (83)10 = (01010011)2
m[1] = y → (121)10 = (01111001)2
m[2] = s → (115)10 = (01110011)2
m[3] = a → (97)10 = (01100001)2
m[4] = d → (100)10 = (01100100)2
m[5] = m → (109)10 = (01101101)2
m[6] = i → (105)10 = (01101001)2
m[7] = n → (110)10 = (01101110)2

1) r[0] = 01010011 XOR 00110110 = (01100101)2 = (101)10 → e


2
2) r[1] = 01111001 XOR 00110110 = (01001111)2 = (79)10 → O
3) r[2] = 01110011 XOR 00110110 = (01000101)2 = (69)10 → E
4) r[3] = 01100001 XOR 00110110 = (01010111)2 = (87)10 → W
5) r[4] = 01100100 XOR 00110110 = (01010010)2 = (82)10 → R
6) r[5] = 01101101 XOR 00110110 = (01011011)2 = (91)10 → [
7) r[6] = 01101001 XOR 00110110 = (01011111)2 = (95)10 → _
8) r[7] = 01101110 XOR 00110110 = (01011000)2 = (88)10 → X

Deci, mesajul m = „Sysadmin” criptat este „eOEWR[_X”

DECRIPTARE

Cript r = eOEWR[_X;
K=26;
S= 20354761
P 0 1 2 3 4 5 6 7
S 2 0 3 5 4 7 6 1
K 50 50 54 54 50 54 50 54

Iniţial i=0, j=0.


i = (i+1) mod 8 = 1 mod 8 = 1.
j = (j+S[i]) mod 8 = (j+S[1]) mod 8 = (0+0) mod 8 = 0

Calculam t:
t=(S[i]+S[j]) mod 8 = (S[1]+S[0]) mod 8 = (0+2) mod 8 = 2

i = chr(ord(r)) XOR K[t]


r[0] = e → (101)10 = (01100101)2
r[1] = O → (79)10 = (01001111)2
r[2] = E → (69)10 = (01000101)2
r[3] = W → (87)10 = (01010111)2
r[4] = R → (82)10 = (01010010)2
r[5] = [ → (91)10 = (01011011)2
r[6] = _ → (95)10 = (01011111)2
r[7] = X → (88)10 = (01011000)2

1) m[0] = 01100101 XOR 00110110 = (01010011)2 = (83)10 → S


2) m[1] = 01001111 XOR 00110110 = (01111001)2 = (121)10 → y
3) m[2] = 01000101 XOR 00110110 = (01110011)2 = (115)10 → s
4) m[3] = 01010111 XOR 00110110 = (01100001)2 = (97)10 → a
5) m[4] = 01010010 XOR 00110110 = (01100100)2 = (100)10 → d
6) m[5] = 01011011 XOR 00110110 = (01101101)2 = (109)10 → m
7) m[6] = 01011111 XOR 00110110 = (01101001)2 = (105)10 → i
8) m[7] = 01011000 XOR 00110110 = (01101110)2 = (110)10 → n

Mesajul criptat r = „eOEWR[_X” decriptat va fi: „Sysadmin”.

You might also like