JavaScript JS SHA256算法源代码JavaScript JS 实现原理

这是完全用JavaScript JS 编写的SHA256算法源代码比特币 Bitcoin BTC 核心依赖算法SHA256源代码/** A JavaScript implementation of the SHA256 hash function.** FILE: sha256.js* VERSION: 0.8* AUTHOR: Christoph Bichlmeier <in...
摘要由CSDN通过智能技术生成

这是完全用JavaScript JS 编写的SHA256算法源代码
比特币 Bitcoin BTC 核心依赖算法SHA256源代码

/* SHA256 logical functions */
function rotateRight(n,x) {
   
	return ((x >>> n) | (x << (32 - n)));
}
function choice(x,y,z) {
   
	return ((x & y) ^ (~x & z));
}
function majority(x,y,z) {
   
	return ((x & y) ^ (x & z) ^ (y & z));
}
function sha256_Sigma0(x) {
   
	return (rotateRight(2, x) ^ rotateRight(13, x) ^ rotateRight(22, x));
}
function sha256_Sigma1(x) {
   
	return (rotateRight(6, x) ^ rotateRight(11, x) ^ rotateRight(25, x));
}
function sha256_sigma0(x) {
   
	return (rotateRight(7, x) ^ rotateRight(18, x) ^ (x >>> 3));
}
function sha256_sigma1(x) {
   
	return (rotateRight(17, x) ^ rotateRight(19, x) ^ (x >>> 10));
}
function sha256_expand(W, j) {
   
	return (W[j&0x0f] += sha256_sigma1(W[(j+14)&0x0f]) + W[(j+9)&0x0f] +
sha256_sigma0(W[(j+1)&0x0f]));
}

/* Hash constant words K: */
var K256 = new Array(
	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
	0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
	0x72be5d74, 
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值