def receive(self, encoded): huffman_encoded_text, huffman_root, key, encrypted, dictionary = encoded # Huffman decoding huffman_decoded_text = huffman_decode(huffman_encoded_text, huffman_root) print "Huffman decoded" print huffman_decoded_text ###### Decryption ###### b = ReducedArrayDecryption(huffman_decoded_text,key,encrypted[0]) decrypted_text = b.decrypt() print "Decrypted text" print decrypted_text ######################## # Run-length decoding rle_decoded_text = invert_rle(decrypted_text) print "RLE inverse" print rle_decoded_text # Burrows-Wheeler Transform bwt_decoded_text = invert_BWT(rle_decoded_text) print "BWT inverse" print bwt_decoded_text # Dictionary decoding decoded_text = dictionary_decoding(bwt_decoded_text, dictionary) #print "Dictionary decoded" #print decoded_text with open('dictionary_decoding_output.txt', 'w') as f: f.write(decoded_text) return decoded_text
from KeyGenerator import KeyGenerator from ReducedArrayEncryption import ReducedArrayEncryption from ReducedArrayDecryption import ReducedArrayDecryption start_value = 3 max_value = 10 factor = 4 k = KeyGenerator() key = k.generate_key(start_value,max_value,factor) print "key: ",key string = "mytextisjusttext" print "string: ",string a = ReducedArrayEncryption(string,key) text_encrypted = a.encrypt() print "text_encrypted",text_encrypted new_text = a.get_text_encrypted(text_encrypted[1]) print "new_text: ", new_text b = ReducedArrayDecryption(new_text,key,text_encrypted[0]) print "original text: ", b.decrypt()
from ReducedArrayDecryption import ReducedArrayDecryption x = ReducedArrayDecryption([35633, 37581],[3, 34, 344],['3', '4', 'b', '5', 'c']) print x.decrypt()