
Understanding RSA: A Simple Guide to Public-Key Math
RSA (Rivest–Shamir–Adleman) is a Public-Key cryptographic algorithm. It involves a public key to encrypt and corresponding private key to decrypt data to transmit securely and to verify digital signature. Step 1: Generate the key Take any 2 large prime numbers p and q Let n = p*q Find the totient of n (Totient of n means the count of the numbers which are less than n and each of the numbers are relatively prime to n. So, for example totient of 11 is 11 , because there are 11 numbers 1,2,3,4,5,6.7,8,9,10 , these are relatively prime to 11. Same way Totient of 12 is 4, because 1,5,7,11 , these 4 numbers are relatively prime to 12, and there is no common factor of 12 and any of these numbers. Easy way to find totient of p*q = (p-1)*(q-1)) ) Step 2: Do the math to encrypt/decrypt If your message is m and cypher is c , then c = m^e mod n -- This is encryption m = c^d mod n -- This is decryption Example Let p = 7 and q = 17 , so n = 7 x 17 = 119 The totient of n (119) = (p-1) (q-1) = (7-1) (
Continue reading on Dev.to
Opens in a new tab


