base64编码和解码在客户端Javascript [英] Base64 encoding and decoding in client-side Javascript

查看:156
本文介绍了base64编码和解码在客户端Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用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问题。它使用<一个href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding\"><$c$c>btoa() 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,有一个 BTOA包Node.js的

For server-side JavaScript, there's a btoa package for Node.JS.

如果你要一个跨浏览器的解决方案,有喜欢的 CryptoJS 或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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆