Welcome to the Hill Cipher Tool!
The Hill cipher is a polygraphic substitution cipher based on linear algebra. Each letter is represented by a number, and a matrix is used as the key.
To Encrypt a Message:
- Set Matrix Size: Choose a size for the key matrix (e.g., 2 for a 2x2 matrix).
- Enter Key Matrix: Fill in the key matrix with numbers. The matrix must be invertible for decryption to be possible. You can also generate a random key.
- Enter Plaintext: Type the message you want to encrypt. It will be automatically padded if its length isn't a multiple of the matrix size.
- Click Encrypt: The encrypted message will appear in the "Output" box.
To Decrypt a Message:
- Set Matrix Size and Key: Use the same matrix size and key that were used for encryption.
- Enter Ciphertext: Paste the encrypted text into the "Ciphertext" field.
- Click Decrypt: The original message will be revealed in the "Output" box.
Note: The determinant of the key matrix must not be zero and must not share any common factors with 26 for the cipher to be decryptable.