Well, no need to worry (unless you were on some phising site). Your credit card info is protected, thanks to something called the RSA Algorithm, used in Public-Key Encyrption (PKE) — the strongest data encryption algorithm known today, and used in most, if not all, of the high-value data submission forms on the Internet. This page will give you a peek into how this algorithm works.

The RSA Algorithm is named for the three people who developed it back in 1978: Ron Rivest, Adi Shamir, and Leonard Adleman, so RSA stands for Rivest, Shamir, and Adleman. Back in the 70s, the computer was still primitive and room-sized, so the algorithm wasn't of much use then, but around the turn of the 21st century, the algorithm was, in effect, rediscovered and began to achieve widespread use throughout the Internet.

The RSA Steps

  1. Choose two prime numbers, p and q.
  2. Get the product, n, of the two numbers (n = pq).
  3. Get the totient, r, of p and q (r = (p - 1)(q - 1)).
  4. Get a number, e, that is less than r and shares no prime factors with r other than 1.
  5. Get another number, d, so that de - 1 = rk where rk equals any multiple of r that will fulfill the equation.

Now that you have the numbers p, q, n, r, e, and d, you can create your public key and your private key. The public key is (e, n), which you would then publish to the world, and the private key is (d, n), which you would keep secret. If someone wants to send you an encrypted message using a predetermined character-to-number mapping system, they would look up your public key and encrypt their message like so:

  • Convert the each of the message's character into its mapped number, m, and have its encrypted equivalent, c, be equal to me mod n. (a mod b is equal to the remainder of a ÷ b)
  • To decrypt the message, you would use your private key and put the encrypted number, c, through m = cd mod n to get the original character.

Example

  1. You generate two prime numbers, p = 7 and q = 11.
  2. n = pq = 7 · 11 = 77
  3. r = (p - 1)(q - 1) = (7 - 1)(11 - 1) = 6 · 10 = 60
  4. e can equal 49 because the prime factors of 60 (2, 3, 5) aren't the prime factor of 49 (which is 7). I choose the smallest possible number for practical reasons, but generally, the higher the number, the better.
  5. Incidently, the smallest possible value for d is also 49, because de = 49 · 49 = 2401 and rk + 1 = (60 · 40) + 1 = 2400 + 1 = 2401. Please note, however, that the chances of d and e being equal are very slim.
  6. Our public key will then be (49, 77) and our private key will be (49, 77).
  7. To encrypt a message, "HI", to send to us, one would look up our public key, (49, 77), and encrypt it as such:
    • Let's say that the char-to-num mapping codes of "H" and "I" are 8 and 9, respectively. Therefore, m1 = 8 and m2 = 9.
    • c1 = 849 mod 77 = 29
    • c2 = 949 mod 77 = 16
    • c = 29  16
  8. To decrypt the message, c, using our private key (49, 77):
    • m1 = 2949 mod 77 = 8
    • m2 = 1649 mod 77 = 9
    • You would map the numbers to their specific character to get the message "HI".

NOTE: For simplicity, small prime numbers were used for this example. In real life, the prime numbers often exceed 1000 or maybe even 100,000. Also, the character-to-number scheme that is normally used is either ASCII or Unicode, and n should never be smaller than your highest number in the char-to-num scheme.