Last active
May 27, 2021 03:14
-
-
Save cbscribe/a161a78f45b0c189ad9aa9fa8dacc49e to your computer and use it in GitHub Desktop.
Manually decrypt text RSA-style, given "N" and "D".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ciphertext = input("Ciphertext: ") | |
m = int(input("m: ")) | |
d = int(input("D: ")) | |
num_digits = len(str(m)) | |
cleartext = "" | |
print("Decrypting (may take a while)...") | |
for i in range(0, len(ciphertext), num_digits): | |
num = int(ciphertext[i:i+num_digits]) | |
cleartext += chr((num ** d) % m) | |
print() | |
print(cleartext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment