Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

Decode Base64 to Hexadecimal string with javascript

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Why not try the following code?:

const buffer = Buffer.from(rawData, 'base64');
const bufString = buffer.toString('hex');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...