<s> from sneakers . modules import Encoder <EOL> from Crypto . Cipher import PKCS1_OAEP <EOL> from Crypto . PublicKey import RSA as cryptoRSA <EOL> class Rsa ( Encoder ) : <EOL> description = """<STR_LIT>""" <EOL> requiredParams = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' + <EOL> '<STR_LIT>' <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' + <EOL> '<STR_LIT>' <EOL> } <EOL> } <EOL> def encode ( self , data ) : <EOL> encode_params = self . params [ '<STR_LIT>' ] <EOL> keystring = open ( encode_params [ '<STR_LIT>' ] ) . read ( ) <EOL> key = cryptoRSA . importKey ( keystring ) <EOL> cipher = PKCS1_OAEP . new ( key ) <EOL> ciphertext = cipher . encrypt ( data ) <EOL> return ciphertext <EOL> def decode ( self , data ) : <EOL> decode_params = self . params [ '<STR_LIT>' ] <EOL> keystring = open ( decode_params [ '<STR_LIT>' ] ) . read ( ) <EOL> key = cryptoRSA . importKey ( keystring ) <EOL> cipher = PKCS1_OAEP . new ( key ) <EOL> message = cipher . decrypt ( data ) <EOL> return message </s>
