Encrypt a short message

2k Views Asked by At

I'm supposed to encrypt a short message, OAHU, using f(p) = (3p + 7) mod 26.

I've tried to understand how to use a modulo, but frankly I just can't seem to wrap my head around it.

If someone could explain the process or at least point me in the right direction, I'd appreciate it.

1

There are 1 best solutions below

0
On BEST ANSWER

The letters OAHU correspond to the numbers $14,0,7$, and $20$ in that order. Substitute these successively for $p$ in the equation

$$f(p)=(3p+7)\bmod{26}\;;$$

I’ll do the first two. For the O we have $p=14$, so we want

$$(3\cdot14+7)\bmod{26}=(42+7)\bmod{26}=49\bmod{26}\;.$$

To find $n\bmod{m}$ you need to divide $n$ by $m$, throw away the quotient, and keep the remainder.

When $n$ is negative this doesn’t work quite the way you probably expect, but that doesn’t happen here. An alternative approach that avoids this technical difficulty is as follows.

  • If $n>m$, subtract $m$ repeatedly until you get a result in the range $0,1,\ldots,m-1$; that result is $n\bmod{m}$.
  • If $n<0$, add $m$ repeatedly until you get a result in the range $0,1,\ldots,m-1$; that result is $n\bmod{m}$.

When you divide $49$ by $26$, you get a quotient of $1$ with a remainder of $20$, so $48\bmod{26}=20$. That corresponds to the letter U, so we encipher the O as U.

For A we have $p=0$, so we want

$$(3\cdot 0+7)\bmod{26}=7\bmod{26}=7\;,$$

since $7$ is already between $0$ and $25$ inclusive. $7$ corresponds to the letter H, so we encipher A as H. The encipherment of OAHU therefore begins UH.

Now see if you can finish the job.