Pure Programmer
Blue Matrix


Cluster Map

Project: Vigenère Cipher

By using interwoven [[Caesar Cipher]]s we can create a more complex polyalphabetic substitution called a [[Vigenère Cipher]]. Write a filter program that encrypts or decrypts text using a Vigenère Cipher. The alphabet to use should be the 95 ASCII printable characters.

The program should accept two command line arguments. The first is the password to use to set up the interwoven ciphers and the second is the encrypt/decrypt mode. If the second argument is "e", the program should take in clear (unencrypted) text on the standard input and write cipher (encrypted) text on the standard output. If the second argument is "d", the program should take in cipher (encrypted) text on the standard input and write clear (unencrypted) text on the standard output.

What is the weakness of this cipher? Is there an input pattern that reveals the password?

Output
$ swiftc VigenereCipher.swift -I . -L . -lUtils VigenereCipher.swift:47:6: warning: variable 'pwdCP' was never mutated; consider changing to 'let' constant var pwdCP:Int = Utils.codepoint_at(password, passwordPos % passwordLen) ~~~ ^ let VigenereCipher.swift:48:6: warning: variable 'shift' was never mutated; consider changing to 'let' constant var shift:Int = alphabet.indexOf(Utils.chr(pwdCP)) ~~~ ^ let error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc VigenereCipher.swift -I . -L . -lUtils VigenereCipher.swift:47:6: warning: variable 'pwdCP' was never mutated; consider changing to 'let' constant var pwdCP:Int = Utils.codepoint_at(password, passwordPos % passwordLen) ~~~ ^ let VigenereCipher.swift:48:6: warning: variable 'shift' was never mutated; consider changing to 'let' constant var shift:Int = alphabet.indexOf(Utils.chr(pwdCP)) ~~~ ^ let error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution