How to base64 encrypt rest message payload
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2023 09:54 AM
Hi, i have created a rest post method and invoking it through business rule . I need to encrypt the payload.. how to do it? Is it done in rest message or in business rule or somewhere else?
Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2023 04:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2023 07:16 AM - edited ‎05-14-2023 07:18 AM
Thank you very much. I see the encrypted payload. My concern is the encrypted value is only 20 characters long alphanumeric value and it remains same even if i modify incident fields as request payload input. Is this expected? Or the encrypted payload should change each time and should increase if i include more fields in the request payload?
Do you know this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2023 07:30 AM
@Swapnil Shirsik - you can decrypt it and validate, for decrypting use this method:
var encryptedPayload = GlideStringUtil.base64Encode(json_payload);
var decryptedPayload = GlideStringUtil.base64Decode(encryptedPayload);
gs.log(decryptedPayload);
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2023 08:06 AM - edited ‎05-14-2023 08:07 AM
Yes, i tried it.. it is showing [Object Object]
I have defined the body as var body={....}
encrypted it
If i send encryptedpayload in r.setrequestBody it will give error 400 unacceptable data.
So I'm stringifying the encrypted payload as
Var stri= JSON.stringify(encryptedPayload)
And now setting this in requestBody as
r.setrequestBody(stri)
So this time I'm getting 200 ok response but the decoded value is same in both cases as [object Object]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2023 08:42 AM
@Swapnil Shirsik - please try this to log object
JSUtil.logObject(decryptedObject, "decryptedObj");