def decrypt(shift, ciphertext): temp = toNum(ciphertext) plaintext = [] for i in temp: i -= shift i %= 26 plaintext.append(i) return toLetter(plaintext)
def encrypt(radius, plaintext): temp = toNum(plaintext) ciphertext = [] j = 0 while i =< radius: while j < plaintext i %= 26 ciphertext.append(i) return toLetter(ciphertext)
def decrypt(alpha, beta, ciphertext): modInv = modularInverse(alpha, 26) if modInv != None: plaintext = toNum(ciphertext) for i in range(len(plaintext)): if ciphertext[i].isalpha(): plaintext[i] = (modInv * (plaintext[i] - beta)) % 26 return toLetter(plaintext) else: return "No MMI for " + str(alpha) + " and 26."
def encrypt(key, plaintext): ciphertext = [] sanitizedKey = sanitizeKey(key) numPlaintext = toNum(plaintext) y = 0 # key index for x in range(len(plaintext)): if plaintext[x].isalpha(): ciphertext.append((numPlaintext[x] + sanitizedKey[y]) % 26) y = (y + 1) % len(sanitizedKey) else: ciphertext.append(plainttext[x]) return toLetter(ciphertext)
def decrypt(key, ciphertext): plaintext = [] sanitizedKey = sanitizeKey(key) numCiphertext = toNum(ciphertext) y = 0 # key index for x in range(len(ciphertext)): if ciphertext[x].isalpha(): plaintext.append((numCiphertext[x] - sanitizedKey[y]) % 26) y = (y + 1) % len(sanitizedKey) else: plaintext.append(ciphertext[x]) return toLetter(plaintext)
def encrypt(alpha, beta, plaintext): ciphertext = toNum(plaintext) for i in range(len(ciphertext)): if plaintext[i].isalpha(): ciphertext[i] = (ciphertext[i] * alpha + beta) % 26 return toLetter(ciphertext)