From d8ab2bbca5e62983b1a4811e750ad6d1c3b1182d Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 21 Apr 2020 23:55:06 +0300 Subject: [PATCH] octet encode decode in encodetest file. Signed-off-by: HeshamTB --- encodetest.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/encodetest.py b/encodetest.py index 970d22b..0a50719 100644 --- a/encodetest.py +++ b/encodetest.py @@ -42,10 +42,22 @@ print(key) import OAEP key = en.generateKeys("encode-test", 2048) -x = int(en.encrypt("test message", (key[en.N], key[en.E]))) +x = int(en.encrypt("test message int to octet string and int to octet string.", (key[en.N], key[en.E]))) print(x) encoded_msg = OAEP.i2osp(x, key[en.N].bit_length()) print(encoded_msg) +char_encoded_message = str() +for num in encoded_msg: + char_encoded_message += chr(num) +print(char_encoded_message) +decoded = list() +for char in char_encoded_message: + decoded.append(int(ord(char))) +#print(decoded) +os2i = OAEP.os2ip(decoded) +#print(os2i) +print(en.decrypt(os2i, key[en.D], key[en.N])) -decoded = OAEP.os2ip(encoded_msg) -print(decoded) + +#decoded = OAEP.os2ip(encoded_msg) +#print(decoded)