Created
March 23, 2016 05:54
-
-
Save subintp/97f87b76ed9a4985c354 to your computer and use it in GitHub Desktop.
RSA/ECB with PKCS1 padding in Python
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
import rsa | |
import base64 | |
# modulus in integer | |
MODULUS = 123456789996582395910301286053968077124788323801012630967456380836472396333396466272319708473453610663848909708214595391668878270127153659315097128748348977528953482874935452127643776505027944666257946919553474879512809890824078158244248097149714260265207481163611166304138228724039676901039297181889888815151 | |
# exponent in integer | |
EXPONENT = 65537 | |
PUBLIC_KEY = rsa.PublicKey(MODULUS, EXPONENT) | |
class Encryptor: | |
@staticmethod | |
def encrypt(message): | |
message = message.encode('utf8') | |
crypto = base64.b64encode(rsa.encrypt(message, PUBLIC_KEY)) # encodes encrypted message in Base64 also | |
return crypto |
Thanks was stuck in this error for 4-5 hours. Really appreciate it
works great :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Decryption