A fun cryptography demonstrator to give libsodium.js an Enigma / substitution-cipher-like UI
Adapting a modern symmetric cipher to an "Engima"-like typewriter experience. This means:
- 1 plaintext character <-> 1 ciphertext character (for the most part)
- typable ciphertext on a keyboard
- "reversible" typing process (decryption to plaintext is the same typable process as "encrypting")
while keeping modern symmetric cipher primitives, provided by libsodium
:
- modern key stretching of the passphrase
- modern cipher with authentication via AEAD construction
- a restricted typable charset of 32 characters
[ !’,.a-z?]
is chosen and all plaintext is interpreted as such abase32
-encoded byte array - keys are derived from passphrase using
Argon2id
vialibsodium.crypto_pwhash
- the nonce is randomly generated and encoded via above
base32
and described as a "preamble" - plaintext bytes are encrypted (currently with
XSalsa20-Poly1305
) vialibsodium.secretbox
- (Plaintext is padded to mod8 characters with trailing spaces (
- (Plaintext is padded to mod8 characters with trailing spaces (
- ciphertext bytes are encoded back to
base32
. The stream cipher construction with typablebase32
ensures a character-by-character substitution cipher-like effect - the MAC is described as a "tamper-proof seal code" and can be used to authenticate