Decode Base64 to Hexadecimal string with javascript

前端 未结 5 1192
有刺的猬
有刺的猬 2020-12-06 09:52

Needing to convert a Base64 string to Hexadecimal with javascript.

Example:

var base64Value = \"oAAABTUAAg==\"

Need conversion m

5条回答
  •  盖世英雄少女心
    2020-12-06 10:22

    Try

    [...atob(base64Value)].map(c=> c.charCodeAt(0).toString(16).padStart(2,0))
    

    let base64Value = "oAAABTUAAg=="
    
    let h= [...atob(base64Value)].map(c=> c.charCodeAt(0).toString(16).padStart(2,0))
    
    console.log( h.join``.toUpperCase() );

提交回复
热议问题