diff options
author | Holden Rohrer <holden.rohrer@gmail.com> | 2019-11-11 23:18:36 -0500 |
---|---|---|
committer | Holden Rohrer <holden.rohrer@gmail.com> | 2019-11-11 23:18:36 -0500 |
commit | eb364b5badef4afb4cc1ce370a36fd089aa61cf7 (patch) | |
tree | ff09b14fc8fa977bafe76f8aebd57a3f5777a514 /final/rsa-encrypt.py | |
parent | 83d23049a685244b7cf0236ebeb1e77cce71ac6e (diff) |
added user entry (except for the hardcoded encrypted data)
Diffstat (limited to 'final/rsa-encrypt.py')
-rw-r--r-- | final/rsa-encrypt.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/final/rsa-encrypt.py b/final/rsa-encrypt.py index de9ba1e..a15fe9d 100644 --- a/final/rsa-encrypt.py +++ b/final/rsa-encrypt.py @@ -1,10 +1,12 @@ -p = 29 +'''p = 29 q = 17 n = p*q tot = (p-1)*(q-1) -e = 3 # Many present strictly for convenience's sake +e = 3 # Many present strictly for convenience's sake''' +n = int(input('n: ')) +e = int(input('e (make sure it\'s relatively prime to p-1 and q-1): ')) -message = 'abcdef' +message = input('message:\n') messagenum = 0 for char in message: messagenum += ord(char) @@ -14,7 +16,6 @@ messageblocks = [] while messagenum > 0: messageblocks.append(messagenum%n) messagenum = (messagenum-messagenum%n)//n -print(messageblocks) def encrypt_block(blk): return (blk ** e) % n |