A041 · RSA · XOR
Cryptography laboratory
Four ways to transform a message: substitution, transposition, XOR and RSA public-key encryption.
Read the full article →Educational experiments, not security tools: the keys are tiny or repeated, so do not use these results for confidential data.
1. Substitution
Shift each Latin letter by a fixed number of places; spaces and punctuation stay unchanged.
Result
Steps
2. Keyed transposition
Write letters in rows under the key, then read the columns in alphabetical key order; equal letters keep their original order.
Result
Steps
This experiment uses A–Z: spaces, accents and punctuation are removed and cannot be restored on decryption.
3. Symmetric XOR
Each UTF-8 byte is combined with the same key byte using XOR. The result is shown in hexadecimal.
Result
Steps
Repeating a single key byte is insecure: this example only demonstrates why XOR is reversible.
4. RSA: Alice and Bob
Bob creates a key pair. Alice uses Bob’s public key to encrypt; Bob uses his private key to decrypt.
How Bob constructs the keys
- Bob chooses p = 61 and q = 53; n = p × q = 3233.
- He computes φ(n) = (61 − 1) × (53 − 1) = 3120.
- He chooses e = 17, coprime to 3120. The public key is (n = 3233, e = 17).
- He finds d = 2753 because 17 × 2753 = 46801 = 15 × 3120 + 1. The private key is d = 2753.
Bob’s public key: (3233, 17)
Bob’s private key (shown here only for learning): 2753
For the letter A: UTF-8 = 65; Alice computes 65^17 mod 3233 = 2790; Bob computes 2790^2753 mod 3233 = 65 and reads A again.
Result
Steps
The primes 61 and 53 are deliberately tiny. Each byte is encrypted separately and no padding is used: this “blackboard RSA” is insecure. Real applications need vetted libraries and RSA-OAEP.