From d23b2d4ae0e5aeec78fc6208d8abfd2604234df1 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 17 Apr 2020 04:43:03 +0300 Subject: [PATCH] test file. Consider writing 'words' to file instead of saving a list in memory. Signed-off-by: HeshamTB --- encodetest.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 encodetest.py diff --git a/encodetest.py b/encodetest.py new file mode 100644 index 0000000..91b7200 --- /dev/null +++ b/encodetest.py @@ -0,0 +1,30 @@ + + +s = 'test message hello awdawdaefe' +print(s) +s_number = int.from_bytes(s.encode('utf-8'),'little') +print(s_number) + +ss = str(s_number.to_bytes(s_number.bit_length(),'little').decode('utf-8')).strip() +print(ss) + +msg_list = list() + +for word in s.split(): + msg_list.append(word) +print(msg_list) + +import rsa as en + +key = en.readKeyFile('key') +enc_list = list() +pub_key = (key[0],key[1]) +for word in msg_list: + enc_list.append(en.encrypt(word,pub_key)) +print(enc_list) + +unenc_list = list() + +for enc_word in enc_list: + unenc_list.append(en.decrypt(enc_word,key[2],key[0]).strip(('\x00'))) +print(unenc_list) \ No newline at end of file