前台js加密实例

1.base64加密

一个字节一般由8位表示,base64加密就是把8位表示转为6为表示,余下2位添0表示,故有个特点不能充分利用空间。

资源下载:jquery.js,base64.js

// `utf8encode` - utf8 encoding only (default: `false`)
        // `utf8decode` - utf8 decoding only (default: `false`)
        // `raw` - both (default: `true`)
        $.base64.utf8encode = true;
        //编码
        var str = $.base64.encode("a");
        alert("base64 decode:" + str);
        //解码
        str = $.base64.decode(str);
        alert("base64 decode:" + str);

2.md5加密

md5加密是一种不可逆的加密方式,

资源下载:jquery.js,md5.js

var str = $.md5("a");
        alert(str);

3.sha1加密

sha1加密方式也是一种不可逆的加密方式,相对来讲要比较安全些。

资源下载:jquery.js,sha1.js

var str = $.sha1("a");
        alert(str);
原文地址:https://www.cnblogs.com/haoke/p/4909645.html