How can we use asymmetric encryption in a flow designer action to encrypt a secret in a rest payload
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 04:42 PM
Hi, I need to pass a secret to another API (outside of service now) within a payload.
The secret is entered as a service catalog item field and becomes an input to my flow designer workflow.
In my action, I am trying to use a public key to encrypt the secret string and then pass it along in base64 to my target system using a rest call.
The intent is to then decrypt that value on the destination using the private key.
I have tried to find ways of making this feasable, i've tried to use script includes with JSEncrypt and CryptoJS, to no avail.
I even tried to use the glydeencrypter for symmetrical encryption but every base64 string created on SNOW with that method, I can't decrypt using openssl, all ciphers were tried and encrypting a value with SNOW does not generate the same encryption although using the same key.
```
var public_key = '010101111000110011001110';
var encr = new GlideEncrypter(public_key);
var clearString = 'abcdefg';
var encrString = encr.encrypt(clearString);
```
generates : +vkYSkAmH9A=
but running :
```
echo -n 'abcdefg' | openssl enc -des-ede-ecb -e -k 010101111000110011001110 --nosalt -a
```
generates : +0bFf69+f0I=
I have been refering to this article :
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0747622
I can't believe I would be the only person with such a requirement
Can anyone help point me in the right direction?
thanks!