资源简介
杂凑密码程序实现(SHA1,MD5)
编程实现SHA1/MD5杂凑密码算法,理解杂凑密码算法的加解密流程
代码片段和文件信息
#include
#include
#include
#include “Sha1.h“
void SHA1_AssignM(unsigned char *bufferWord *pMD)
{
unsigned char *P;
Word B0B1B2B3;
SWord i;
P=buffer;
for(i=0;i<64;i+=4)
{
B0 = (Word) *P++;
B1 = (Word) *P++;
B2 = (Word) *P++;
B3 = (Word) *P++;
*pMD = (B0 << 24) | (B1<< 16) | (B2 << 8) | B3;
pMD++;
}
}
void SHA1_AssignW(Word *pMDWord *pWD)
{
SWord i;
for(i=0;i<16;i++)
{
pWD[i] = pMD[i];
}
for(i=16;i<80;i++)
{
pWD[i]=pWD[i-3]^pWD[i-8]^pWD[i-14]^pWD[i-16];
pWD[i]=(pWD[i]<<1) | (pWD[i]>>31);
}
}
void SHA1_Process(unsigned char *bufferWord HData[5])
{
Word ABCDEK1K2K3K4tempt1;
Word temp1temp2;
Word pMD[16] pWD[80];
//SWord len=0;
SWord i;
评论
共有 条评论