How to implement base64 Decoding by JavaScript
This article will explain in detail how to achieve base64 decoding in JavaScript. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Implementing base64 Decoding
Function base64_decode (data) {
Var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
Var o1
O2
O3
H2
H3
H4
H5
Bits
I = 0
Ac = 0
Dec = ""
Tmp_arr = []
If (! data) {
Return data
}
Data + = ""
Do {
H2 = b64.indexOf (data.charAt (iTunes +))
H3 = b64.indexOf (data.charAt (iTunes +))
H4 = b64.indexOf (data.charAt (iTunes +))
H5 = b64.indexOf (data.charAt (iTunes +))
Bits = (H2 > 8) & 0xff
O3 = bits & 0xff
If (h4 = = 64) {
Tmp_ ARR [ac + +] = String.fromCharCode (o1)
} else if (h5 = = 64) {
Tmp_ ARR [ac + +] = String.fromCharCode (o1, O2)
} else {
Tmp_ arr [ac + +] = String.fromCharCode (o1, o2, o3)
}
} while (I < data.length)
Dec = tmp_arr.join ("")
Dec = utf8_decode (dec)
Return dec
} this is the end of the article on "how to implement base64 decoding in JavaScript". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.