def decrypt(self, text): """Decrypt text and return the result""" output = [] text = process_string(text) for char in text: output.append(english_char(char)) return ''.join(output)
def decrypt(self, text, a, b): """Decrypt text and return the result D(x) = a^-1 ( x - b ) mod m """ output = "" text = process_string(text) count = 0 a_inv = 0 while count < m: flag = (a * count) % m if flag == 1: a_inv = count break; count = count + 1 for char in text: if char.isspace(): output += " " else: char_code = a_inv*(lookup_table[char]-b) % m for k, v in lookup_table.items(): if v == char_code: break output += k return output
def encrypt(self, text): """Encrypt text and return the result""" output = [] text = process_string(text) for char in text: output.append(keyword_char(char)) return ''.join(output)
def decrypt(self, text): """Decrypt text and return the result""" output = "" text = process_string(text) for char in text: if char.isspace(): output += " " else: output += lookup_table[char] return output
def encrypt(self, text, a, b): """Encrypt text and return the result E(x) = ( ax + b ) mod m """ output = "" text = process_string(text) for char in text: if char.isspace(): output += " " else: char_code = (a*lookup_table[char] + b) % m for k, v in lookup_table.items(): if v == char_code: break output += k return output