# -*- coding: utf-8 -*- import textoperations import sys import os import codecs #In python a string is a list. By calling Alphabet[x] we get the character for that number sequence. This we can use as our character -> number mapping. Alphabet = textoperations.getAlphabet() def vigenereCipher(inputString, keyString, encrypt): """ Cipher a string with the Vigenere cipher. @type inputString: String @type inputString: The text to encrypt or decrypt. @type keyString: String @type keyString: The key for the cipher. @type encrypt: Boolean @param encrypt: If the algorithm should encrypt or decrypt. @rtype: String """ inputIndex = 0 keyLength = len(keyString) outText = "" if(keyLength == 0): print("Key missing") return "Key missing" for char in inputString: #calculate what key character to use and look up the number in the alphabet keyInteger = Alphabet.index(keyString[inputIndex % keyLength])
def getSweRandom(): return getAlphabetRandom(textoperations.getAlphabet())