- Any computer with Python 3.

Execute these commands to store`python3`

The parameters print out, as shown below.

p = 7 q = 23 n = p * q print(p, q, n)

The parameters print out, as shown below.

phin = (p-1) * (q-1) print(p, q, n, phin)

Let's use **e = 5**

First let's set e and perform a simple multiplication.(d * e) mod phin = 1

Execute these commands. As shown below, 20 * 5 is 100, as you'd expect.

Now let's use modular arithmetic, with a modulus of

e = 5 print(20 * e)

Modulus 132 means there is no number larger than 131. Adding 1 to 131 makes it roll back to 0. The numbers are on a ring, as shown below.

Execute these commands. As shown below, 132 modulus phin is zero.

Now let's calculate the result for values of

print(100 % phin) print(130 % phin) print(131 % phin) print(132 % phin)

Execute these commands:

We weren't able to find a good value for

print((20 * e) % phin) print((21 * e) % phin) print((22 * e) % phin) print((23 * e) % phin) print((24 * e) % phin) print((25 * e) % phin) print((26 * e) % phin) print((27 * e) % phin)

Execute these commands:

We have a winner, as shown below! Let's use

print((50 * e) % phin) print((51 * e) % phin) print((52 * e) % phin) print((53 * e) % phin)

She publishes her public key to the cloud.

Cueball wants to send Meghan this message:

We can only send numbers. Let's encode that message with ASCII using the table below.

Hi!

So the message is:

A public key contains two numbers:

72 105 33

Execute these commands:

As shown below, the encrypted message is

print(72 ** e % n) print(105 ** e % n) print(33 ** e % n)

As shown below, the decrypted message is

d = 53 print(151 ** d % n) print(119 ** d % n) print(157 ** d % n)

## C 401.1: Cueball's Keys (15 pts)

Cueball will use these values:Calculate Cueball's public and private keys.

p = 13 q = 41 e = 7The flag is Cueball's Public Key, like this:

(161,5)

## C 401.2: Message to Cueball (15 pts)

Meghan sends this message to Cueball. Decrypt it.

460, 364, 144, 153, 501, 402, 19, 311, 501, 280, 501, 80, 153, 382, 296, 153, 311

Hint: use the chr() and ord() functionsThe flag is the decrypted message.

Cueball image

Megan image

Cloud image

Posted 3-23-16 by Sam Bowne

Winners pages added 8-6-16

Attack server name updated 4-4-17

Ported to new scoring engine 7-8-19

Upgraded to Python 3 7-8-2020

Typo fixed 7-15-2020