trevorswann / CipherTool

Command line cipher tool for encoding and decoding text with different types of ciphers.
MIT License
1 stars 0 forks source link

Hill Cipher #8

Open trevorswann opened 3 years ago

trevorswann commented 3 years ago

Add in functionality for Hill cipher. Uses linear algebra to encipher/decipher. Each letter is represented by a number mod 26, usually A=0, B=1, ..., Z=25. To encrypt a message, each set of n letters of plaintext is multiplied by an invertible nn key matrix. Mod 26, then you'll get your cipher text letters, 0 being A, 1 being B, and so on. To decrypt you'll do the same process backwards. Break the cipher text up into blocks of n letters, multiply by the inverse of the key nn matrix, then mod 26 and you'll get the numbers corresponding to your plaintext letters. Will have to see difficulty of implementation to decide, but it may be best to limit the size of n to between 2 and 5. Anything above that gets a bit more tricky with larger and larger matrices, and is a bit unnecessary.

trevorswann commented 3 years ago

This could be enhanced to add a mono-alphabetic substitution cipher on top of it, where the user can enter their own key alphabet rather than using A=0, B=1, ..., Z=25. But that will be easy to do after the fact.