next up previous contents
Next: How Many Letters Can Up: Lecture 9: The RSA Previous: How Nikita Decrypts a   Contents


Encoding a Phrase in a Number

Think of a sequence of letters and spaces as a number in base $ 27$. Let a single-space correspond to 0, the letter $ A$ to 1, $ B$ to 2, ..., $ Z$ to 26. Thus, e.g., ``HARVARD'' denotes a number written in base $ 27$. The corresponding number written in decimal is $ 1808939906$:

   HARVARD$\displaystyle \quad\leftrightarrow\quad
8 + 27\cdot 1 + 27^2\cdot 18 + 27^3\cdot22 + 27^4\cdot1+27^5\cdot18 + 27^6\cdot 4
= 1808939906
$

To recover the digits of the number, repeatedly divide by $ 27$:

\begin{displaymath}
\begin{array}{lcrcrr}
1808939906 &=& 66997774\cdot 27 &+& 8...
...
66997774 &=&2481399\cdot 27 &+& 1 & \text{A}\\
\end{array}\end{displaymath}

and so on.



Subsections

William A Stein 2001-10-01