Giter Site home page Giter Site logo

base64-utf8's Introduction

base64-utf8

无依赖utf8字符base64编/解码模块,可安全用于微信小程序

安装

nodejs方式安装

npm install base64-utf8 --save

bower方式安装

bower install base64-utf8

用法

require方式

var base64 = require('base64-utf8');

var str = "base64中文字符测试";
var encodeString = base64.encode(str); // 编码
var decodeString = base64.decode(encodeString); // 解码

console.log(encodeString); // YmFzZTY05Lit5paH5a2X56ym5rWL6K+V
console.log(decodeString); // base64中文字符测试

引入方式

<script src="bower_components/base64-utf8/dist/base64.min.js"></script>
<script>
var str = "base64中文字符测试";
var encodeString = base64.encode(str); // 编码
var decodeString = base64.decode(encodeString); // 解码

console.log(encodeString); // YmFzZTY05Lit5paH5a2X56ym5rWL6K+V
console.log(decodeString); // base64中文字符测试
</script>

base64-utf8's People

Contributors

vilien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

base64-utf8's Issues

Arabic support

When I try to encode and decode an Arabic test, I become the error 'base64 malformed!'
Example:

var str = "فرهادو";
var encodeString = base64.encode(str); // 编码
var decodeString = base64.decode(encodeString); // 解码

console.log(encodeString);
console.log(decodeString);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.