Last active
April 24, 2024 12:42
-
-
Save eaccmk/501177b2834a20caa995626849f32ebd to your computer and use it in GitHub Desktop.
Base64 decoding using postman (Working in Postman v7.34.0 version)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const base64EncodedString = "YWJjZDEyMzQ=" ; // abcd1234 | |
console.log("INPUT >> ",base64EncodedString," <<"); | |
if(!base64EncodedString.length > 0) { | |
pm.test("FAIL ", () => {throw new Error(" 'base64EncodedString' can not be empty !!")}); | |
}else{ | |
try{ | |
var wordArray = CryptoJS.enc.Base64.parse(base64EncodedString); | |
var decodedString = CryptoJS.enc.Utf8.stringify(wordArray); | |
console.log("OUTPUT >> ",decodedString," <<"); | |
pm.test(decodedString,function(){}); | |
}catch(e){ | |
pm.test("FAIL", () => {throw new Error("Malformed 'base64EncodedString', please verify the input again.")}); | |
} | |
} | |
/* | |
@uthor : https://medium.com/@eaccmk | |
@date : 19-10-2020 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment