加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

asp实现的sha1加密解密程式

发布时间:2023-10-09 10:53:38 所属栏目:Asp教程 来源:
导读:在百度找的几个asp sha1加密结果和asp.net的sha1加密结果不一样,asp.net sha1加密完后是40位,网上找的asp sha1加密是64位,还以为asp.net做了截取,但是asp的64位加密结果并没有包含asp.net的40位结果,看来找到的
在百度找的几个asp sha1加密结果和asp.net的sha1加密结果不一样,asp.net sha1加密完后是40位,网上找的asp sha1加密是64位,还以为asp.net做了截取,但是asp的64位加密结果并没有包含asp.net的40位结果,看来找到的版本和asp.net的加密算法不一样。
 
最后还是靠翻墙用google找到了一个js版本的sha1加密代码结合asp使用后结果和asp.net的sha1加密一模一样。。看来技术类的文字用度娘还是搞不过谷歌啊。。随便fuck下中国的防火墙。。谷歌也给封了。
 
asp sha1加密源代码如下,和asp.net的sha1加密结果一致:

复制代码 代码如下:
<script language="javascript" type="text/javascript" runat="server">
/*
 * 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 - lowercase; 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") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
/*
 * 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] = len;
  var w = Array(80);

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章