Skip to content

How RSA Works

  • pick 2 prime numbers (p,q), which are large numbers, they are private
  • n=p×q
  • ϕ(n)=(p1)(q1) which returns the number of numbers coprime with N (doesn't share a common factor with it)
  • choose e which must:
    • 1<e<ϕ(n)
    • coprime with n and ϕ(n)
    • e is a constant between (3, 5, 17, 65537)
  • choose d which must:
    • d×emodϕ(n)=1
    • d=e1modϕ(n)
  • public key is (e, n); private key is (d, n)
  • to Encrypt use: memodn, where m is the original message
  • to Decrypt use: cdmodn, where c is the cipher text
  • The message is converted to numbers