jquery.json.js 使用sha1.js 怎么使用

javascript用户密码加密,js密码加密
10002次浏览
今天总结几种javascript用户密码加密的方法,虽然前端当中密码加密不经常用,一般在后端加密之后存入数据库。今天主要列举一下前端js加密方法,以后可能也用得到!
1、base64加密
在页面中引入base64.js文件,调用方法为:
&!DOCTYPE HTML&
&meta charset=&utf-8&&
&title&base64加密&/title&
&script type=&text/javascript& src=&base64.js&&&/script&
&script type=&text/javascript&&
var b = new Base64();
var str = b.encode(&admin:admin&);
alert(&base64 encode:& + str);
     //解密
str = b.decode(str);
alert(&base64 decode:& + str);
2、md5加密
在页面中引用md5.js文件,调用方法为
&!DOCTYPE HTML&
&meta charset=&utf-8&&
&title&md5加密&/title&
&script type=&text/ecmascript& src=&md5.js&&&/script&
&script type=&text/javascript&&
var hash = hex_md5(&123dafd&);
alert(hash)
3、sha1加密
据说这是最安全的加密
页面中引入sha1.js,调用方法为
&!DOCTYPE HTML&
&meta charset=&utf-8&&
&title&sha1加密&/title&
&script type=&text/ecmascript& src=&sha1.js&&&/script&
&script type=&text/javascript&&
var sha = hex_sha1('mima;)
alert(sha)
以上几种方法,希望对您有所帮助!
相关文章:
关键词搜索&&&&sha1.js(js版sha1加密)
sha1.js(js版sha1加密)
sha1.js(js版sha1加密)
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:
VIP下载&&免积分60元/年(1200次)
您可能还需要
开发技术下载排行JavaScript实现SHA-1加密算法的方法
作者:jing31
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了JavaScript实现SHA-1加密算法的方法,实例分析了使用javascript实现SHA-1加密算法的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了JavaScript实现SHA-1加密算法的方法。分享给大家供大家参考。具体实现方法如下:
调用方法:hex_sha1即可。
代码如下:/*
&* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
&* in FIPS PUB 180-1
&* By lizq
&* Configurable variables.
var hexcase = 0; /* hex output format. 0 - 1 - uppercase */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
&* The main function to calculate message digest
function hex_sha1(s){
&&& return binb2hex(core_sha1(AlignSHA1(s)));
&* Perform a simple self-test to see if the VM is working
function sha1_vm_test(){
&&& return hex_sha1("abc") == "a16aba3ec9cd0d89d";
&* Calculate the SHA-1 of an array of big-endian words, and a bit length
function core_sha1(blockArray){
&&& var x = blockA // append padding
&&& var w = Array(80);
&&& var a = ;
&&& var b = -;
&&& var c = -;
&&& var d = ;
&&& var e = -;
&&& for (var i = 0; i & x. i += 16) // 每次处理512位 16*32
&&&&&&& var olda =
&&&&&&& var oldb =
&&&&&&& var oldc =
&&&&&&& var oldd =
&&&&&&& var olde =
&&&&&&& for (var j = 0; j & 80; j++) // 对每个512位进行80步操作
&&&&&&&&&&& if (j & 16)
&&&&&&&&&&&&&&& w[j] = x[i + j];
&&&&&&&&&&& else
&&&&&&&&&&&&&&& w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
&&&&&&&&&&& var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
&&&&&&&&&&& e =
&&&&&&&&&&& d =
&&&&&&&&&&& c = rol(b, 30);
&&&&&&&&&&& b =
&&&&&&&&&&& a =
&&&&&&& a = safe_add(a, olda);
&&&&&&& b = safe_add(b, oldb);
&&&&&&& c = safe_add(c, oldc);
&&&&&&& d = safe_add(d, oldd);
&&&&&&& e = safe_add(e, olde);
&&& return new Array(a, b, c, d, e);
&* Perform the appropriate triplet combination function for the current
&* iteration
&* 返回对应F函数的值
function sha1_ft(t, b, c, d){
&&& if (t & 20)
&&&&&&& return (b & c) | ((~ b) & d);
&&& if (t & 40)
&&&&&&& return b ^ c ^
&&& if (t & 60)
&&&&&&& return (b & c) | (b & d) | (c & d);
&&& return b ^ c ^ // t&80
&* Determine the appropriate additive constant for the current iteration
&* 返回对应的Kt值
function sha1_kt(t){
&&& return (t & 20) ?
: (t & 40) ?
: (t & 60) ? - : -;
&* Add integers, wrapping at 2^32. This uses 16-bit operations internally
&* to work around bugs in some JS interpreters.
&* 将32位数拆成高16位和低16位分别进行相加,从而实现 MOD 2^32 的加法
function safe_add(x, y){
&&& var lsw = (x & 0xFFFF) + (y & 0xFFFF);
&&& var msw = (x && 16) + (y && 16) + (lsw && 16);
&&& return (msw && 16) | (lsw & 0xFFFF);
&* Bitwise rotate a 32-bit number to the left.
&* 32位二进制数循环左移
function rol(num, cnt){
&&& return (num && cnt) | (num &&& (32 - cnt));
&* The standard SHA1 needs the input string to fit into a block
&* This function align the input string to meet the requirement
function AlignSHA1(str){
&&& var nblk = ((str.length + 8) && 6) + 1, blks = new Array(nblk * 16);
&&& for (var i = 0; i & nblk * 16; i++)
&&&&&&& blks[i] = 0;
&&& for (i = 0; i & str. i++)
&&&&&&& blks[i && 2] |= str.charCodeAt(i) && (24 - (i & 3) * 8);
&&& blks[i && 2] |= 0x80 && (24 - (i & 3) * 8);
&&& blks[nblk * 16 - 1] = str.length * 8;
&* Convert an array of big-endian words to a hex string.
function binb2hex(binarray){
&&& var hex_tab = hexcase ? "ABCDEF" : "abcdef";
&&& var str = "";
&&& for (var i = 0; i & binarray.length * 4; i++) {
&&&&&&& str += hex_tab.charAt((binarray[i && 2] && ((3 - i % 4) * 8 + 4)) & 0xF) +
&&&&&&& hex_tab.charAt((binarray[i && 2] && ((3 - i % 4) * 8)) & 0xF);
&* calculate MessageDigest accord to source message that inputted
function calcDigest(){
&&& var digestM = hex_sha1(document.SHAForm.SourceMessage.value);
&&& document.SHAForm.MessageDigest.value = digestM;
希望本文所述对大家的javascript程序设计有所帮助。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具jQuery.encoding.digests.sha1 这是一个实现 摘要加密数据的 插件。 Crypt_De algrithms 解密 238万源代码下载-
&文件名称: jQuery.encoding.digests.sha1
& & & & &&]
&&所属分类:
&&开发工具: JavaScript
&&文件大小: 2 KB
&&上传时间:
&&下载次数: 2
&&提 供 者:
&详细说明:这是一个实现SHA1摘要加密数据的jQuery插件。-This is a SHA1 digest encrypted data jQuery plugin.
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&jQuery.encoding.digests.sha1.js
&近期下载过的用户:
&输入关键字,在本站238万海量源码库中尽情搜索:7961人阅读
算法与数据结构(5)
前端与js技术(11)
在一般网站开发中,用户登陆的密码都是明码发送的,这样是很不安全的.
解决方法:在提交前,用JavaScript将用户密码进行sha1或md5加密.下面是js源码:
&* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
&* in FIPS PUB 180-1
&* Version 2.1a Copyright Paul Johnston 2000 - 2002.
&* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
&* Distributed under the BSD License
&* See http://pajhome.org.uk/crypt/md5 for details.
&* Configurable variables. You may need to tweak these to be compatible with
&* the server-side, but the defaults work in most cases.
var hexcase = 0;& /* hex output format. 0 - 1 - uppercase&&&&&&& */
var b64pad& = &&; /* base-64 pad character. &=& for strict RFC compliance&& */
var chrsz&& = 8;& /* bits per input character. 8 - ASCII; 16 - Unicode&&&&& */
&* These are the functions you'll usually want to call
&* They take string arguments and return either hex or base-64 encoded strings
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
&* Perform a simple self-test to see if the VM is working
function sha1_vm_test()
& return hex_sha1(&abc&) == &a16aba3ec9cd0d89d&;
&* Calculate the SHA-1 of an array of big-endian words, and a bit length
function core_sha1(x, len)
& /* append padding */
& x[len && 5] |= 0x80 && (24 - len % 32);
& x[((len + 64 && 9) && 4) + 15] =
& var w = Array(80);
& var a =& ;
& var b = -;
& var c = -;
& var d =& ;
& var e = -;
& for(var i = 0; i & x. i += 16)
&&& var olda =
&&& var oldb =
&&& var oldc =
&&& var oldd =
&&& var olde =
&&& for(var j = 0; j & 80; j++)
&&&&& if(j & 16) w[j] = x[i + j];
&&&&& else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
&&&&& var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
&&&&&&&&&&&&&&&&&&&&&& safe_add(safe_add(e, w[j]), sha1_kt(j)));
&&&&& c = rol(b, 30);
&&& a = safe_add(a, olda);
&&& b = safe_add(b, oldb);
&&& c = safe_add(c, oldc);
&&& d = safe_add(d, oldd);
&&& e = safe_add(e, olde);
& return Array(a, b, c, d, e);
&* Perform the appropriate triplet combination function for the current
&* iteration
function sha1_ft(t, b, c, d)
& if(t & 20) return (b & c) | ((~b) & d);
& if(t & 40) return b ^ c ^
& if(t & 60) return (b & c) | (b & d) | (c & d);
& return b ^ c ^
&* Determine the appropriate additive constant for the current iteration
function sha1_kt(t)
& return (t & 20) ?&
: (t & 40) ?&
&&&&&&&& (t & 60) ? - : -;
&* Calculate the HMAC-SHA1 of a key and some data
function core_hmac_sha1(key, data)
& var bkey = str2binb(key);
& if(bkey.length & 16) bkey = core_sha1(bkey, key.length * chrsz);
& var ipad = Array(16), opad = Array(16);
& for(var i = 0; i & 16; i++)
&&& ipad[i] = bkey[i] ^ 0x;
&&& opad[i] = bkey[i] ^ 0x5C5C5C5C;
& var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
& return core_sha1(opad.concat(hash), 512 + 160);
&* Add integers, wrapping at 2^32. This uses 16-bit operations internally
&* to work around bugs in some JS interpreters.
function safe_add(x, y)
& var lsw = (x & 0xFFFF) + (y & 0xFFFF);
& var msw = (x && 16) + (y && 16) + (lsw && 16);
& return (msw && 16) | (lsw & 0xFFFF);
&* Bitwise rotate a 32-bit number to the left.
function rol(num, cnt)
& return (num && cnt) | (num &&& (32 - cnt));
&* Convert an 8-bit or 16-bit string to an array of big-endian words
&* In 8-bit function, characters &255 have their hi-byte silently ignored.
function str2binb(str)
& var bin = Array();
& var mask = (1 && chrsz) - 1;
& for(var i = 0; i & str.length * i += chrsz)
&&& bin[i&&5] |= (str.charCodeAt(i / chrsz) & mask) && (32 - chrsz - i%32);
&* Convert an array of big-endian words to a string
function binb2str(bin)
& var str = &&;
& var mask = (1 && chrsz) - 1;
& for(var i = 0; i & bin.length * 32; i += chrsz)
&&& str += String.fromCharCode((bin[i&&5] &&& (32 - chrsz - i%32)) & mask);
&* Convert an array of big-endian words to a hex string.
function binb2hex(binarray)
& var hex_tab = hexcase ? &ABCDEF& : &abcdef&;
& var str = &&;
& for(var i = 0; i & binarray.length * 4; i++)
&&& str += hex_tab.charAt((binarray[i&&2] && ((3 - i%4)*8+4)) & 0xF) +
&&&&&&&&&& hex_tab.charAt((binarray[i&&2] && ((3 - i%4)*8& )) & 0xF);
&* Convert an array of big-endian words to a base-64 string
function binb2b64(binarray)
& var tab = &ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/&;
& var str = &&;
& for(var i = 0; i & binarray.length * 4; i += 3)
&&& var triplet = (((binarray[i&& && 2] && 8 * (3 -& i&& %4)) & 0xFF) && 16)
&&&&&&&&&&&&&&& | (((binarray[i+1 && 2] && 8 * (3 - (i+1)%4)) & 0xFF) && 8 )
&&&&&&&&&&&&&&& |& ((binarray[i+2 && 2] && 8 * (3 - (i+2)%4)) & 0xFF);
&&& for(var j = 0; j & 4; j++)
&&&&& if(i * 8 + j * 6 & binarray.length * 32) str += b64
&&&&& else str += tab.charAt((triplet && 6*(3-j)) & 0x3F);
&* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
&* Digest Algorithm, as defined in RFC 1321.
&* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
&* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
&* Distributed under the BSD License
&* See http://pajhome.org.uk/crypt/md5 for more info.
&* Configurable variables. You may need to tweak these to be compatible with
&* the server-side, but the defaults work in most cases.
var hexcase = 0;& /* hex output format. 0 - 1 - uppercase&&&&&&& */
var b64pad& = &&; /* base-64 pad character. &=& for strict RFC compliance&& */
var chrsz&& = 8;& /* bits per input character. 8 - ASCII; 16 - Unicode&&&&& */
&* These are the functions you'll usually want to call
&* They take string arguments and return either hex or base-64 encoded strings
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
&* Perform a simple self-test to see if the VM is working
function md5_vm_test()
& return hex_md5(&abc&) == &cd24fb0de17f72&;
&* Calculate the MD5 of an array of little-endian words, and a bit length
function core_md5(x, len)
& /* append padding */
& x[len && 5] |= 0x80 && ((len) % 32);
& x[(((len + 64) &&& 9) && 4) + 14] =
& var a =& ;
& var b = -;
& var c = -;
& var d =& ;
& for(var i = 0; i & x. i += 16)
&&& var olda =
&&& var oldb =
&&& var oldc =
&&& var oldd =
&&& a = md5_ff(a, b, c, d, x[i+ 0], 7 , -);
&&& d = md5_ff(d, a, b, c, x[i+ 1], 12, -);
&&& c = md5_ff(c, d, a, b, x[i+ 2], 17,& );
&&& b = md5_ff(b, c, d, a, x[i+ 3], 22, -);
&&& a = md5_ff(a, b, c, d, x[i+ 4], 7 , -);
&&& d = md5_ff(d, a, b, c, x[i+ 5], 12,& );
&&& c = md5_ff(c, d, a, b, x[i+ 6], 17, -);
&&& b = md5_ff(b, c, d, a, x[i+ 7], 22, -);
&&& a = md5_ff(a, b, c, d, x[i+ 8], 7 ,& );
&&& d = md5_ff(d, a, b, c, x[i+ 9], 12, -);
&&& c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
&&& b = md5_ff(b, c, d, a, x[i+11], 22, -);
&&& a = md5_ff(a, b, c, d, x[i+12], 7 ,& );
&&& d = md5_ff(d, a, b, c, x[i+13], 12, -);
&&& c = md5_ff(c, d, a, b, x[i+14], 17, -);
&&& b = md5_ff(b, c, d, a, x[i+15], 22,& );
&&& a = md5_gg(a, b, c, d, x[i+ 1], 5 , -);
&&& d = md5_gg(d, a, b, c, x[i+ 6], 9 , -);
&&& c = md5_gg(c, d, a, b, x[i+11], 14,& );
&&& b = md5_gg(b, c, d, a, x[i+ 0], 20, -);
&&& a = md5_gg(a, b, c, d, x[i+ 5], 5 , -);
&&& d = md5_gg(d, a, b, c, x[i+10], 9 ,& );
&&& c = md5_gg(c, d, a, b, x[i+15], 14, -);
&&& b = md5_gg(b, c, d, a, x[i+ 4], 20, -);
&&& a = md5_gg(a, b, c, d, x[i+ 9], 5 ,& );
&&& d = md5_gg(d, a, b, c, x[i+14], 9 , -);
&&& c = md5_gg(c, d, a, b, x[i+ 3], 14, -);
&&& b = md5_gg(b, c, d, a, x[i+ 8], 20,& );
&&& a = md5_gg(a, b, c, d, x[i+13], 5 , -);
&&& d = md5_gg(d, a, b, c, x[i+ 2], 9 , -);
&&& c = md5_gg(c, d, a, b, x[i+ 7], 14,& );
&&& b = md5_gg(b, c, d, a, x[i+12], 20, -);
&&& a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
&&& d = md5_hh(d, a, b, c, x[i+ 8], 11, -);
&&& c = md5_hh(c, d, a, b, x[i+11], 16,& );
&&& b = md5_hh(b, c, d, a, x[i+14], 23, -);
&&& a = md5_hh(a, b, c, d, x[i+ 1], 4 , -);
&&& d = md5_hh(d, a, b, c, x[i+ 4], 11,& );
&&& c = md5_hh(c, d, a, b, x[i+ 7], 16, -);
&&& b = md5_hh(b, c, d, a, x[i+10], 23, -);
&&& a = md5_hh(a, b, c, d, x[i+13], 4 ,& );
&&& d = md5_hh(d, a, b, c, x[i+ 0], 11, -);
&&& c = md5_hh(c, d, a, b, x[i+ 3], 16, -);
&&& b = md5_hh(b, c, d, a, x[i+ 6], 23,& );
&&& a = md5_hh(a, b, c, d, x[i+ 9], 4 , -);
&&& d = md5_hh(d, a, b, c, x[i+12], 11, -);
&&& c = md5_hh(c, d, a, b, x[i+15], 16,& );
&&& b = md5_hh(b, c, d, a, x[i+ 2], 23, -);
&&& a = md5_ii(a, b, c, d, x[i+ 0], 6 , -);
&&& d = md5_ii(d, a, b, c, x[i+ 7], 10,& );
&&& c = md5_ii(c, d, a, b, x[i+14], 15, -);
&&& b = md5_ii(b, c, d, a, x[i+ 5], 21, -);
&&& a = md5_ii(a, b, c, d, x[i+12], 6 ,& );
&&& d = md5_ii(d, a, b, c, x[i+ 3], 10, -);
&&& c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
&&& b = md5_ii(b, c, d, a, x[i+ 1], 21, -);
&&& a = md5_ii(a, b, c, d, x[i+ 8], 6 ,& );
&&& d = md5_ii(d, a, b, c, x[i+15], 10, -);
&&& c = md5_ii(c, d, a, b, x[i+ 6], 15, -);
&&& b = md5_ii(b, c, d, a, x[i+13], 21,& );
&&& a = md5_ii(a, b, c, d, x[i+ 4], 6 , -);
&&& d = md5_ii(d, a, b, c, x[i+11], 10, -);
&&& c = md5_ii(c, d, a, b, x[i+ 2], 15,& );
&&& b = md5_ii(b, c, d, a, x[i+ 9], 21, -);
&&& a = safe_add(a, olda);
&&& b = safe_add(b, oldb);
&&& c = safe_add(c, oldc);
&&& d = safe_add(d, oldd);
& return Array(a, b, c, d);
&* These functions implement the four basic operations the algorithm uses.
function md5_cmn(q, a, b, x, s, t)
& return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
function md5_ff(a, b, c, d, x, s, t)
& return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
function md5_gg(a, b, c, d, x, s, t)
& return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
function md5_hh(a, b, c, d, x, s, t)
& return md5_cmn(b ^ c ^ d, a, b, x, s, t);
function md5_ii(a, b, c, d, x, s, t)
& return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
&* Calculate the HMAC-MD5, of a key and some data
function core_hmac_md5(key, data)
& var bkey = str2binl(key);
& if(bkey.length & 16) bkey = core_md5(bkey, key.length * chrsz);
& var ipad = Array(16), opad = Array(16);
& for(var i = 0; i & 16; i++)
&&& ipad[i] = bkey[i] ^ 0x;
&&& opad[i] = bkey[i] ^ 0x5C5C5C5C;
& var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
& return core_md5(opad.concat(hash), 512 + 128);
&* Add integers, wrapping at 2^32. This uses 16-bit operations internally
&* to work around bugs in some JS interpreters.
function safe_add(x, y)
& var lsw = (x & 0xFFFF) + (y & 0xFFFF);
& var msw = (x && 16) + (y && 16) + (lsw && 16);
& return (msw && 16) | (lsw & 0xFFFF);
&* Bitwise rotate a 32-bit number to the left.
function bit_rol(num, cnt)
& return (num && cnt) | (num &&& (32 - cnt));
&* Convert a string to an array of little-endian words
&* If chrsz is ASCII, characters &255 have their hi-byte silently ignored.
function str2binl(str)
& var bin = Array();
& var mask = (1 && chrsz) - 1;
& for(var i = 0; i & str.length * i += chrsz)
&&& bin[i&&5] |= (str.charCodeAt(i / chrsz) & mask) && (i%32);
&* Convert an array of little-endian words to a string
function binl2str(bin)
& var str = &&;
& var mask = (1 && chrsz) - 1;
& for(var i = 0; i & bin.length * 32; i += chrsz)
&&& str += String.fromCharCode((bin[i&&5] &&& (i % 32)) & mask);
&* Convert an array of little-endian words to a hex string.
function binl2hex(binarray)
& var hex_tab = hexcase ? &ABCDEF& : &abcdef&;
& var str = &&;
& for(var i = 0; i & binarray.length * 4; i++)
&&& str += hex_tab.charAt((binarray[i&&2] && ((i%4)*8+4)) & 0xF) +
&&&&&&&&&& hex_tab.charAt((binarray[i&&2] && ((i%4)*8& )) & 0xF);
&* Convert an array of little-endian words to a base-64 string
function binl2b64(binarray)
& var tab = &ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/&;
& var str = &&;
& for(var i = 0; i & binarray.length * 4; i += 3)
&&& var triplet = (((binarray[i&& && 2] && 8 * ( i&& %4)) & 0xFF) && 16)
&&&&&&&&&&&&&&& | (((binarray[i+1 && 2] && 8 * ((i+1)%4)) & 0xFF) && 8 )
&&&&&&&&&&&&&&& |& ((binarray[i+2 && 2] && 8 * ((i+2)%4)) & 0xFF);
&&& for(var j = 0; j & 4; j++)
&&&&& if(i * 8 + j * 6 & binarray.length * 32) str += b64
&&&&& else str += tab.charAt((triplet && 6*(3-j)) & 0x3F);
下面说说调用方法:
&type=&text/javascript&&src=&md5.js&&&
if&(md5_vm_test())&{&&&&&&&&document.getElementById('admin_pws').value&=&hex_md5(document.getElementById('admin_pws').value);&&&&}&&&& else&{&&&& &&&&alert(&md5加密模块初始化失败&);&&&&}&&&&
sha1调用方法跟MD5相似;
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1024726次
积分:11687
积分:11687
排名:第846名
原创:143篇
转载:21篇
评论:549条
文章:30篇
阅读:312857
(3)(2)(5)(5)(1)(1)(1)(2)(2)(3)(3)(2)(2)(2)(11)(3)(1)(2)(1)(5)(1)(2)(45)(10)(1)(3)(10)(9)(4)(2)(5)(6)(1)(1)(2)(9)(6)(3)}

我要回帖

更多关于 sha1.js 使用方法 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信