问题描述
有没有使用base64编码在JavaScript中的任何方法,可以用来连接code和德code字符串?
Are there any methods in JavaScript that could be used to encode and decode a string using base64 encoding?
推荐答案
有些浏览器,如火狐,Chrome,Safari浏览器,Opera和IE10 +可以在本地处理Base64编码。看看这个<一个href=\"http://stackoverflow.com/questions/246801/how-can-you-en$c$c-to-base64-using-javascript/247261#247261\">Stackoverflow问题。它使用<$c$c>btoa()$c$c>和 ATOB()
功能的。
Some browsers such as Firefox, Chrome, Safari, Opera and IE10+ can handle Base64 natively. Take a look at this Stackoverflow question. It's using btoa()
and atob()
functions.
有关服务器端的JavaScript,有一个。
For server-side JavaScript, there's a btoa package for Node.JS.
如果你要一个跨浏览器的解决方案,有喜欢的或code,如:
If you are going for a cross-browser solution, there are existing libraries like CryptoJS or code like:
<一个href=\"http://ntt.cc/2008/01/19/base64-en$c$cr-de$c$cr-with-javascript.html\">http://ntt.cc/2008/01/19/base64-en$c$cr-de$c$cr-with-javascript.html
对于后者,则需要彻底的测试跨浏览器兼容的功能。和错误。
With the latter, you need to thoroughly test the function for cross browser compatibility. And error has already been reported.
这篇关于base64编码和解码在客户端Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!