简体   繁体   English

将node.js Buffer(BASE64)更改为jQuery

[英]Change node.js Buffer(BASE64) to jQuery

Could you help me please, I had a program which written with Node.js. 您能帮我吗,我有一个用Node.js编写的程序。 It has this part: 它包含以下部分:

    var b = new Buffer(text, 'base64');
    var s = b.toString('hex');  

Do you have any idea, how could I this code change to jQuery? 您有什么主意,如何将这段代码更改为jQuery? I tried this, but It is not give a good values: 我试过了,但是并没有给出很好的值:

var text = "ACfACRv7aEcAAAAAAAD//w=="; //23,31 was the value
var b = atob(text);
console.log(b);
var s = b.toString('hex');
console.log(s);

Thank you in advance. 先感谢您。

Convert Base64 into hex : 将Base64转换为十六进制:

var base64Image = 'MjMsMzE='; var base64Image ='MjMsMzE =';

console.log(convertToHex(base64Image)); console.log(convertToHex(base64Image));

function convertToHex(base64) { 函数convertToHex(base64){

 var hex = ''; for(var i=0;i<base64.length;i++) { hex += ''+base64.charCodeAt(i).toString(16); } return hex; 

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM