Cracking RSA Code – The World’s Most Important Code? 

RSA code is the basis of all important data transfer.  Encrypted data that needs to be sent between two parties, such as banking data or secure communications relies on the techniques of RSA code.  RSA code was invented in 1978 by three mathematicians (Rivest, Shamir and Adleman).  Cryptography relies on numerous mathematical techniques from Number Theory – which until the 1950s was thought to be a largely theoretical pursuit with few practical applications.  Today RSA code is absolutely essential to keeping digital communications safe.

To encode a message using the RSA code follow the steps below:

1) Choose 2 prime numbers p and q (let’s say p=7 and q=5)

2) Multiply these 2 numbers together (5×7 = 35).  This is the public key (m) – which you can let everyone know. So m = 35.

3) Now we need to use an encryption key (e).   Let’s say that e = 5.  e is also made public. (There are restrictions as to what values e can take – e must actually be relatively prime to (p-1)(q-1) )

4) Now we are ready to encode something.  First we can assign 00 = A, 01 = B, 02 = C, 03 = D, 04 = E etc. all the way to 25 = Z.  So the word CODE is converted into: 02, 14, 03, 04.

5) We now use the formula: C = ye (mod m) where y is the letter we want to encode.  So for the letters CODE we get: C = 025 = 32 (mod 35). C = 145 = 537824 which is equivalent to 14 (mod 35). C = 035 = 33 (mod 35).  C = 045 = 1024 which is equivalent to 09 (mod 35).  (Mod 35 simply mean we look at the remainder when we divide by 35).  Make use of an online modulus calculator!   So our coded word becomes: 32 14 33 09.


This form of public key encryption forms the backbone of the internet and the digital transfer of information.  It is so powerful because it is very quick and easy for computers to decode if they know the original prime numbers used, and exceptionally difficult to crack if you try and guess the prime numbers.  Because of the value of using very large primes there is a big financial reward on offer for finding them.  The world’s current largest prime number is over 17 million digits long and was found in February 2013.   Anyone who can find a prime 100 million digits long will win $100,000.

To decode the message 11 49 41 we need to do the following:

1) In RSA encryption we are given both m and e. These are public keys.  For example we are given that m = 55 and e = 27.  We need to find the two prime numbers that multiply to give 55.  These are p = 5 and q = 11.

2) Calculate (p-1)(q-1).  In this case this is (5-1)(11-1) = 40.  Call this number theta.

3) Calculate a value d such that de = 1 (mod theta).  We already know that e is 27.  Therefore we want 27d = 1 (mod 40).  When d = 3 we have 27×3 = 81 which is 1 (mod 40).  So d = 3.

4) Now we can decipher using the formula: y = C^d (mod m), where C is the codeword.  So for the cipher text 11 49 41:  y = 113 = 11 (mod 55).  y = 493 = 04 (mod 55). y = 413 = 6 (mod 55).

5) We then convert these numbers back to letters using A = 00, B = 01 etc.  This gives the decoded word as: LEG.

If you enjoyed this post you might also like:

How Are Prime Numbers Distributed? Twin Primes Conjecture. Discussion on studying prime numbers.

Cracking ISBN and Credit Card Codes. The mathematics behind ISBN codes and credit card codes

IB Revision

Screen Shot 2018-03-19 at 4.35.19 PM

If you’re already thinking about your coursework then it’s probably also time to start planning some revision, either for the end of Year 12 school exams or Year 13 final exams. There’s a really great website that I would strongly recommend students use – you choose your subject (HL/SL/Studies if your exam is in 2020 or Applications/Analysis if your exam is in 2021), and then have the following resources:

Screen Shot 2018-03-19 at 4.42.05 PM.pngThe Questionbank takes you to a breakdown of each main subject area (e.g. Algebra, Calculus etc) and each area then has a number of graded questions. What I like about this is that you are given a difficulty rating, as well as a mark scheme and also a worked video tutorial.  Really useful!

Screen Shot 2019-07-27 at 10.02.40 AM

The Practice Exams section takes you to ready made exams on each topic – again with worked solutions.  This also has some harder exams for those students aiming for 6s and 7s and the Past IB Exams section takes you to full video worked solutions to every question on every past paper – and you can also get a prediction exam for the upcoming year.

I would really recommend everyone making use of this – there is a mixture of a lot of free content as well as premium content so have a look and see what you think.