aboutsummaryrefslogtreecommitdiff
path: root/final
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-11-11 23:03:23 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-11-11 23:03:23 -0500
commit0ef3d4cde99a8288339338d3ed9285a71c404236 (patch)
treee6c2e1d3e33217bb0fb2e67a3794fe37bd1af6f2 /final
parent303437435f4b6ec660a8b289055fa190e1028328 (diff)
fixed endianness bugs
Diffstat (limited to 'final')
-rw-r--r--final/rsa-decrypt.py8
-rw-r--r--final/rsa-encrypt.py1
2 files changed, 5 insertions, 4 deletions
diff --git a/final/rsa-decrypt.py b/final/rsa-decrypt.py
index 335ed68..d05b351 100644
--- a/final/rsa-decrypt.py
+++ b/final/rsa-decrypt.py
@@ -17,13 +17,13 @@ def decrypt_block(blk):
decrypted = [decrypt_block(block) for block in encrypted]
messagenum = 0
-for block in decrypted:
- messagenum += block
- messagenum *= n
+for blockind in range(len(decrypted)):
+ block = decrypted[blockind]
+ messagenum += block * n ** blockind
message = ''
while messagenum > 0:
- message += chr(messagenum%128)
+ message = chr(messagenum%128) + message
messagenum = (messagenum-messagenum%128)//128
print(message)
diff --git a/final/rsa-encrypt.py b/final/rsa-encrypt.py
index 05cf562..de9ba1e 100644
--- a/final/rsa-encrypt.py
+++ b/final/rsa-encrypt.py
@@ -14,6 +14,7 @@ messageblocks = []
while messagenum > 0:
messageblocks.append(messagenum%n)
messagenum = (messagenum-messagenum%n)//n
+print(messageblocks)
def encrypt_block(blk):
return (blk ** e) % n