资源简介
codeproject上的共享工程,源地址:https://www.codeproject.com/Articles/2463/CSHA-A-C-Class-Implementation-of-the-SHA-Hash-A,压缩包里包含SHA1.h和SHA1.cpp文件,不能设置免费所以设置了最低分,欢迎交流暗号271888395。
代码片段和文件信息
/*
100% free public domain implementation of the SHA-1 algorithm
by Dominik Reichl
Web: http://www.dominik-reichl.de/
See header file for version history and test vectors.
*/
// If compiling with MFC you might want to add #include “StdAfx.h“
#define _CRT_SECURE_NO_WARNINGS
#include “SHA1.h“
#define SHA1_MAX_FILE_BUFFER (32 * 20 * 820)
// Rotate p_val32 by p_nBits bits to the left
#ifndef ROL32
#ifdef _MSC_VER
#define ROL32(p_val32p_nBits) _rotl(p_val32p_nBits)
#else
#define ROL32(p_val32p_nBits) (((p_val32)<<(p_nBits))|((p_val32)>>(32-(p_nBits))))
#endif
#endif
#ifdef SHA1_LITTLE_ENDIAN
#define SHABLK0(i) (m_block->l[i] = \
(ROL32(m_block->l[i]24) & 0xFF00FF00) | (ROL32(m_block->l[i]8) & 0x00FF00FF))
#else
#define SHABLK0(i) (m_block->l[i])
#endif
#define SHABLK(i) (m_block->l[i&15] = ROL32(m_block->l[(i+13)&15] ^ \
m_block->l[(i+8)&15] ^ m_block->l[(i+2)&15] ^ m_block->l[i&15]1))
// SHA-1 rounds
#define S_R0(vwxyzi) {z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v5);w=ROL32(w30);}
#define S_R1(vwxyzi) {z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v5);w=ROL32(w30);}
#define S_R2(vwxyzi) {z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v5);w=ROL32(w30);}
#define S_R3(vwxyzi) {z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v5);w=ROL32(w30);}
#define S_R4(vwxyzi) {z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v5);w=ROL32(w30);}
#pragma warning(push)
// Disable compiler warning ‘Conditional expression is constant‘
#pragma warning(disable: 4127)
CSHA1::CSHA1()
{
m_block = (SHA1_WORKSPACE_BLOCK*)m_workspace;
Reset();
}
#ifdef SHA1_WIPE_VARIABLES
CSHA1::~CSHA1()
{
Reset();
}
#endif
void CSHA1::Reset()
{
// SHA1 initialization constants
m_state[0] = 0x67452301;
m_state[1] = 0xEFCDAB89;
m_state[2] = 0x98BADCFE;
m_state[3] = 0x10325476;
m_state[4] = 0xC3D2E1F0;
m_count[0] = 0;
m_count[1] = 0;
}
void CSHA1::Transform(UINT_32* pState const UINT_8* pBuffer)
{
UINT_32 a = pState[0] b = pState[1] c = pState[2] d = pState[3] e = pState[4];
memcpy(m_block pBuffer 64);
// 4 rounds of 20 operations each loop unrolled
S_R0(abcde 0); S_R0(eabcd 1); S_R0(deabc 2); S_R0(cdeab 3);
S_R0(bcdea 4); S_R0(abcde 5); S_R0(eabcd 6); S_R0(deabc 7);
S_R0(cdeab 8); S_R0(bcdea 9); S_R0(abcde10); S_R0(eabcd11);
S_R0(deabc12); S_R0(cdeab13); S_R0(bcdea14); S_R0(abcde15);
S_R1(eabcd16); S_R1(deabc17); S_R1(cdeab18); S_R1(bcdea19);
S_R2(abcde20); S_R2(eabcd21); S_R2(deabc22); S_R2(cdeab23);
S_R2(bcdea24); S_R2(abcde25); S_R2(eabcd26); S_R2(deabc27);
S_R2(cdeab28); S_R2(bcdea29); S_R2(abcde30); S_R2(eabcd31);
S_R2(deabc32); S_R2(cdeab33); S_R2(bcdea34); S_R2(abcde35);
S_R2(eabcd36); S_R2(deabc37); S_R2(c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7259 2012-06-20 01:21 SHA1.cpp
文件 8436 2012-06-20 01:25 SHA1.h
文件 4042 2018-01-19 13:54 CSHA1ClassDesc
- 上一篇:通过串口控制步进电机
- 下一篇:基于Simbad平台的机器人避障模拟与实现
相关资源
- MD5算法详细流程(pdf)
- MD5碰撞工具 可以指定MD5值
- Hash计算工具
- 我写的sha1源码
- 获取文件md5值的超实用方便的工具.
- 快速MD5 碰撞生成器
- VS2010求值MD5的代码
- 信息隐藏 二值图像的隐藏 MD5
- hmac加密算法的JS文件hmac-sha1.js
- 安全码校对工具
- PB MD5利用系统winapi实现(绝对好用)
- PB调用系统自带的DLL 实现MD5
- md5解密工具破解版好用
- md5算法流程图
- MD5SHA1CRC32数字签名校验工具
- pbfunc外部函数扩展
- RSADSAAESDES加解密
- HMAC-MD5算法 keil C实现代码
- MD5_加密算法程序_C51验证可以用
- cmd5破解账户密码
- Md5模型的max导入导出脚本
- Excel md5加密宏
- 哈希计算工具MD5 MD4 SHA1 SHA256 SHA384 S
- 比特币OKcoin利用API自动交易程序
- servlet中md5加密
- 联想L-VK8M890G(M2VLE-RH)BIOS支持AMD520
- 适用于云盘和谐视频的安全文件MD5值
- 用于excel的md5宏xla
- 计算文件hash值的源代码,包含crcmd2
- 王小云教授的论文+md5的碰撞
评论
共有 条评论