Home / Portfolio / Substitution Cipher
LOGIC2026

Substitution Cipher.

A symmetric substitution cipher in C with random key generation. Live demo below.

A classic substitution cipher built around a 72-character alphabet (A–Z, a–z, 0–9, plus ten common symbols). On startup the program runs a Fisher–Yates shuffle to generate a random mapping key, then exposes a four-option menu: encrypt, decrypt, regenerate the key, or exit.

Encryption walks each input character, looks it up in the original alphabet, and substitutes the character at the same index in the shuffled key; decryption does the reverse. Characters outside the alphabet (spaces, line breaks) pass through untouched.

The C source uses the Windows API for timed status messages — the browser version is a faithful JavaScript port of the same logic so you can watch the substitution happen character by character.

Live demo

Try it yourself.

A random substitution key is generated when this page loads (Fisher–Yates shuffle of 72 characters: A–Z, a–z, 0–9, plus ,./;:@#$%!). Type a message and click Encrypt — characters outside the alphabet pass through untouched. Decrypt reverses the substitution using the same key. Hit Regenerate Key to shuffle a new mapping.

Active key
A–Z a–z 0–9 ,./;:@#$%! →
Input · message0 chars
Output · result0 chars
Ready. Type a message and hit Encrypt.
Substitution map (first 24 characters)
Start · Next

Need a small script like this?

Logic work, automation scripts, and clean algorithm implementations — send a brief.

Start a Project →