Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 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 Answer

0 votes
by (71.8m points)

Why not try the following code?:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...