Be careful - this part is safe:
```
let decoded = Buffer.from(toDecode, 'base64')
```
".toString()" will only work if the buffer contains "string" data.
------------------------------
Hermann Stamm-Wilbrandt
Compiler Level 3 support, IBM DataPower Gateways
IBM
Boeblingen
------------------------------
Original Message:
Sent: Mon August 26, 2024 06:39 PM
From: srikanth talluri
Subject: How to decode base64 encoded string with gateway script in DataPower gateway.
Hi Steve,
Thanks for your quick reply.
Now I am able to decode string.
Thank you.
------------------------------
srikanth talluri
Original Message:
Sent: Mon August 26, 2024 06:09 PM
From: Steve Linn
Subject: How to decode base64 encoded string with gateway script in DataPower gateway.
Hi Srikanth,
To decode a base64 encoded string:
let toDecode = 'dXNlcmlkOnBhc3N3b3Jk'; // base-64 encoded userid:password
let decoded = Buffer.from(toDecode, 'base64').toString();
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Sun August 25, 2024 08:54 PM
From: srikanth talluri
Subject: How to decode base64 encoded string with gateway script in DataPower gateway.
Hi,
I have a requirement to extract user id and password from X-Authorization header.
I am using gateway script to extract X-Authorization header value which is in base64 encoded format.
When i try to decode extracted header value i tried with below buffer function , I am getting request in buffer data format. Can you please help with the steps to extract result value in plain text.
var AuthHeader = new Buffer('Zm9vAGJhcg==','base64');
Thanks.
------------------------------
srikanth talluri
------------------------------