使用javascript将Base64解码为十六进制字符串 [英] Decode Base64 to Hexadecimal string with javascript
问题描述
$ b 示例:
code> var base64Value =oAAABTUAAg ==
需要转换方法
输出(解码数据(十六进制)) A0000005350002
是正确的,因为我可以使用此网站 http://tomeko.net/online_tools/base64.php ?lang = en
并在Base64字符串中输入 oAAABTUAAg ==
并获得 A0000005350002
我试过了什么?
https://github.com/carlo/ jquery-base64
https://jsfiddle.net/gabrieleromanato/qaght/
我发现了很多问题
atob()然后charCodeAt()会给你二进制& toString(16)会给你十六进制数据。
function base64toHEX(base64){ var raw = atob(base64); var HEX =''; for(i = 0; i
Needing to convert a Base64 string to Hexadecimal with javascript.
Example:
var base64Value = "oAAABTUAAg=="
Need conversion method
Output (Decoded data (hexadecimal)) A0000005350002
I know this is correct because I can use this website http://tomeko.net/online_tools/base64.php?lang=en
and punch in Base64 string of oAAABTUAAg==
and get A0000005350002
What have I tried?
https://github.com/carlo/jquery-base64
https://jsfiddle.net/gabrieleromanato/qaght/
I have found a lot of questions
atob() then charCodeAt() will give you binary & toString(16) will give you hex.
function base64toHEX(base64) {
var raw = atob(base64);
var HEX = '';
for ( i = 0; i < raw.length; i++ ) {
var _hex = raw.charCodeAt(i).toString(16)
HEX += (_hex.length==2?_hex:'0'+_hex);
}
return HEX.toUpperCase();
}
console.log(base64toHEX("oAAABTUAAg=="));
这篇关于使用javascript将Base64解码为十六进制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!