how to use RSA encryption keys to encrypt a string

Harish30
Kilo Contributor

We have a requirement where we need to integrate with a third party tool using REST method.

We have been given a RSA public key and we need to encrypt a given string using RSA encryption before passing it on to the tool using POST.

We know of GlideEncrypter api which uses 3DES method to encrypt by default.

how do we use RSA encryption?

4 REPLIES 4

-O-
Kilo Patron
Kilo Patron

You could transform one of the libraries listed on the RSA and ECC in JavaScript page of Stanford.

You than need to store the RSA public key somewhere (maybe a custom table).

Than you use whatever the encryption routine of the chosen library is.

The example on jsencrypt project's page might also be of great help.

In theory what you need to do is the encrypt your text using a public key and the RSA method. The recipient than can decrypt your message using the matching private key only the recipient has.

-O-
Kilo Patron
Kilo Patron

If you could post the public key you are supposed to use, I could have a crack at it.

crpranividya
Tera Contributor

Hi János,

I have the same requirement to encrypt the string using RSA_PKCS1 algorithm in ServiceNow. 

Could you please elaborate more with the solution you have provided above to achieve this? 

Thanks,

Vidya

Hello, so you have a public key and want to use it to encrypt some text?