Skip to content

CrypTools/VigenereCipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vigenere Cipher

Secure cipher but now breakable

How it works

At its core, the vigenere cipher is several Caesar ciphers, with a different shift value depending on the key. It can be computed simply by hand, through the use of a vigenere table. In code, it can be done using modulo arithmetic.

Encoding

To encode, we first convert every letter to a number between 0 and 25, where A is 0, and Z is 25. If the key is shorter than the message, it is repeated until they are the same length, i.e. if the message is cryptography, and the key is secretkey:

msg = cryptography
key = secretkeysec

The ith character of the output O, can be computed from the message M, and key K using the follwing formula:

O[i] = (M[i] + K[i]) mod 26

Decoding

Decoding the output O, into the message M knowing the key K, is just as simple:

M[i] = (O[i] - K[i]) mod 26

Implementations

Language Encrypt Decrypt
Javascript encrypt.js decrypt.js
Python encrypt.py decrypt.py
C vigenere.c vigenere.c

Running the tests

Tests are automatically handled by Travis CI.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details