However, RSA does not work with any value for N, e and d. M = pow(c, d, N) # Decryption, d is a private value Setup RSA is based on modular exponentiation in a group N such that if we have a message m, a public key e and a private key d we can compute the ciphertext c as:Ĭ = pow(m, e, N) # Encryption, e and N are public valuesĪnd compute the original message from the ciphertext as:
This is different from symmetric-key cryptosystems such as AES which use the same key for encryption and decryption.
This means that encryption and decryption use different components.įor encryption, we use a public component that everybody can use to encrypt messages.įor decryption, we use a private component that only the person who wants to decrypt messages may know. RSA is a widely used public-key (also known as asymmetric-key) cryptosystem.