Experts,
I am new to Postman JS script and I need to convert a Python RSA encryption script in into a Postman Pre-request JS script. The Python script is as below :
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5
import base64
dict = {
"value": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmxCTfF/v15C044btDUflNud//JLT/pZN1cqKEYWYGY4FiLThHW8inWPeKaflCH7nrUO9CywXqB8v7kfYJIjvJv1xv0Ah5ghsQtmiscXPFkbpKlu6rpEimzh5Fy7ZYmPQ9JQoXoggCkFeYKQds581shdpiCj+Xi6UKdjcx3v4RalFTJtrY2eAJQ1ArEbFL6CtV5JAIfKEZ3VAv/txW1d3w2evMmdkdTXV35JxbobKYADdFx2/GhvkEiH6yfrSbDV4b1ewvG9NI0J5dk3642GfozjEVO7D0RW/EA3IAin5krYwaGsHCyPxVxbAexPPTDHZSsyUMpKHJK9+EPWm1t2WGwIDAQAB"
}
def getEncryptedText(rsaKey, secret):
keyDER = base64.b64decode(rsaKey)
keyPub = RSA.importKey(keyDER)
cipherRSA = PKCS1_v1_5.new(keyPub)
ciphertext = cipherRSA.encrypt(str.encode(secret))
emsg = base64.b32encode(ciphertext)
return emsg.decode()
uid = 'mytext'
public_key = dict['value']
encrypted_pubkey = getEncryptedText(public_key,uid)
print(encrypted_pubkey)
Can anybody show me the direction? or help please ?