Affine Cipher: Encrypt and Decrypt Text in Your Browser
The Affine Cipher tool encrypts and decrypts text with the affine cipher, a classical substitution method based on E(x) = (a·x + b) mod 26. Choose a value for a that is coprime to 26 and a value for b from 0 to 25. Decryption uses the modular inverse of a; when a is 1, encryption becomes a Caesar shift.
Affine Cipher is a browser-based tool for encrypting and decrypting text with the affine cipher. This classical substitution method maps each letter using the formula E(x) = (a·x + b) mod 26. Use it to explore the cipher, test key values, or work through an encryption example without installing a separate program.
The key has two values. The value a must be coprime to 26 so the mapping can be reversed; valid values are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. The value b can be any number from 0 to 25. For decryption, the process multiplies by the modular inverse of a. When a is 1, the encryption reduces to a Caesar shift.
Plain text is readable before encryption, while ciphertext is the transformed result. Converting between them can help you inspect how a classical cipher works or check a result against a known example. The affine cipher operates on a 26-letter alphabet, and its key requirements ensure that the letter mapping is invertible.
The tool runs entirely in your browser. Your input is processed on your device and is not sent to a server; once the page has loaded, the tool also works offline. You can use it without handing your text to a third-party page.
This tool can help developers and DevOps engineers test or explain a simple cipher, and it is also useful for learners exploring encryption concepts. Use it to experiment with the formula, check sample outputs, and understand how the key values affect the mapping.
Step 1: Enter or paste the text you want to process. You can also drop your content into the tool.
Step 2: Choose whether to encrypt or decrypt the text. The affine cipher uses values for a and b as its keys.
Step 3: Set a to a value coprime to 26 and set b to a value from 0 to 25. These key values determine the letter mapping.
Step 4: Run the operation and review the result. Copy the output when you are ready to use it.
Use case: Check an affine cipher implementation by comparing its output with a value you already know.
Use case: Explore how the affine cipher behaves by encrypting sample text with different valid values for a and b.
Use case: Process text locally instead of sending your input to a third-party page.
Use case: Demonstrate the relationship between the affine cipher and the Caesar shift by using a = 1.
Use case: Practice decryption and see how the modular inverse of a reverses the letter mapping.
Use case: Prepare an example of classical substitution encryption for a programming lesson or technical explanation.