I'm trying to decode a javascript base64 string. The encoded string is from a dataUri. It is
<a href="data:application/octet-stream;charset=utf-16le;base64,//5mAG8AbwAgAGIAYQByAAoA">text file</a>
I'm trying to decode "//5mAG8AbwAgAGIAYQByAAoA" which is supposed to give "foo bar" as output. When I click the anchor tag it downloads a file as expected with the same expected string "foo bar" in it.
If I use atob('//5mAG8AbwAgAGIAYQByAAoA') I'm not getting the desired output
var a=atob('//5mAG8AbwAgAGIAYQByAAoA');
console.log(a);
I've even tried to give "utf8" as second arguement and no luck :(
How to extract the original encoded string from this dataUri? Thanks :)
btoa('foo bar')gives me"Zm9vIGJhcg==", thenatob("Zm9vIGJhcg==")gives mefoo barare you sur about your base64 string ?5mAG8AbwAgAGIAYQByis not a Base64 version offoo bar; it is the Base64 version ofæ`ðð(+ SO trimmed some invalid chars); I'd argue that's more of an auth string.