Skip to content

Locks and Keys

Public and private keys · RSA-OAEP · RSA-PSS

Make a key pair. Encrypt and open a note. Then sign it and check the signature.

Start here

Can someone send you a private note without first sharing a password? Try it in four steps. No maths needed.

Real cryptography, running in your browser. Use example text, not real secrets.

Why RSA here, and what this demo is not

RSA-OAEP lets you encrypt a short note directly with a public key. Modern protocols often use public-key operations to establish a shared key, then encrypt messages with symmetric cryptography. Iron Letter compares the two directly, and HPKE Envelope shows a hybrid encryption construction.

This teaching demo uses real browser cryptography. It makes the private key exportable so Step 4 can reuse the RSA pair for signing. Production systems commonly restrict key export and use separate pairs for encryption and signing.

For the mathematics behind RSA, visit Educational RSA, for a step-by-step explanation.

Step 1 Make a pair

You are Sam. Generate your public key and matching private key.

Step 2 Encrypt a note to you

Maya has only your public key. Write her note, then encrypt it.

This RSA-OAEP setup has a 190-byte message limit.

Why the counter can run ahead of what you typed

The limit counts UTF-8 bytes, not characters. ASCII letters use one byte; accented letters and emoji can use several.

Hybrid encryption establishes a shared key and uses it to encrypt longer messages. Explore that in HPKE Envelope.

Step 3 Open it — and see what opening proves

Try your key, a different key, and a note from a stranger.

Open it with your private key

Now try the wrong key

Predict first — optional

Can an unrelated private key open the same encrypted note?

Can a stranger send you a note?

Predict first — optional

A stranger encrypts their own note using only your public key. Try opening it.

Step 4 The same pair, a different job

Decryption does not identify the sender. Sign with your private key; Maya checks with your public key. She must also know that key is yours.

Predict first — optional

Check it with the public key

Check the signature, then edit the note and check again.

Quick check — which key did which job?

What each job does, and does not, establish

Which key each operation uses and what it does not establish
JobKey usedWhat it does NOT establish
EncryptThe recipient’s public keyWho sent the note
DecryptThe recipient’s private keyWho sent the note
SignThe signer’s private keySecrecy, or whether the note is true
VerifyThe signer’s public keyWhose key it is, unless you already know

Three questions

Check your understanding. No score or saved answers.

How this demo checks its own results

On load, your browser checks published test cases, including ones it must reject.