I'm trying to run two simple functions that I wrote for PyCrypto with PyCryptodome. Here are the functions with the related class member definitions:
import Crypto.PublicKey.RSA as RSA
class MyRSA():
n = "123..." # these are actually very long string...
p = "345..."
u = "567..."
q = "789..."
e = long(65537)
t = (long(n), e, long(d), long(p), long(q), long(u))
key = RSA.construct(t)
def DecryptText(self, text):
chunk_size = 128
enc_vec = [text[i:i+chunk_size] for i in range(0, len(text),
chunk_size)]
plain_text = ''
for x in enc_vec:
plain_text += MyRSA.key.decrypt(x)
return plain_text
def EncryptText(self, text):
chunk_size = 128
text_vec = [text[i:i+chunk_size] for i in range(0, len(text),
chunk_size)]
enc_text = ''
for x in text_vec:
enc_text += MyRSA.key.encrypt(x, '')[0]
return enc_text
The two functions EncryptText and DecryptText use the PyCrypto methods encrypt and decrypt which are no longer mantained in PyCryptodome (a NotImplemented error is raised when they are called by external code). Can anyone help me to convert them to code which is compliant with PyCryptodome? Thanks in advance!