salah satu jenis algoritma kunci a-simetris adalah RSA , berikut adalah copian materi yang q dapet dari dosen

1. RSA membangkitkan kunci

a.generate 2 prime number p and q

ex: p= 7 , q =19

b. let n = p*q

c. let m= (p-1) * (q-1 )

d. Choose a small number, e coprime to m, means that the largest number that can exactly divide both e and m (their greatest common divisor, or gcd) is 1. Euclid’s algorithm is used to find the gcd of two numbers
e = 2 => gcd(e, 108) = 2 (no)
e = 3 => gcd(e, 108) = 3 (no)
e = 4 => gcd(e, 108) = 4 (no)
e = 5 => gcd(e, 108) = 1 (yes!)

e. Find d, such that de % m = 1.This is equivalent to finding d which satisfies de = 1 + nm where n is any integer. We can rewrite this as d = (1 + nm) / e. Now we work through values of n until an integer solution for e is found:
n = 0 => d = 1 / 5 (no)
n = 1 => d = 109 / 5(no)
n = 2 => d = 217 / 5(no)
n = 3 => d = 325 / 5= 65(yes!)

f. Public Key
n = 133
e = 5

Private Key
n = 133
d = 65

g. Enkripsi

C = pe % n
= 65 % 133
= 7776 % 13 = 62

P = plain text, C = cipher text

h. deskripsi

P = cd % n
= 6265 % 133
= 62 * 6264 % 133
= 62 * (622)32 % 133
= 62 * 384432 % 133
= 62 * (3844 % 133)32 % 133
= 62 * 12032 % 133
= 2666 % 133 = 6
P = plain text, C = cipher text
aq dah coba buat pake bahasa c++

selamat mencoba

pake c++

Iklan