pgmd5.cpp
来自「本软件采用MD5算法生成消息摘要,并且具有针对自然攻击的计算检测错误率的功能」· C++ 代码 · 共 39 行
CPP
39 行
#include "stdafx.h"
#include "PgMD5.h"
void Bitconstgen(unsigned short *bitf)
{
//bitf[0-15] is the value of the i-th bit from 0 to 15 and
//bitf[16-31] is the value of the i-th bit complement from 0 to 15.
unsigned short i,j;
for (i=0;i<16;i++) bitf[i]=1;
for (i=0;i<16;i++)
{
for(j=0;j<i;j++)
bitf[i]*=2;
bitf[i+16]=bitf[i]^65535;
}
}
void Packetgen(int nByte,unsigned short *uPacket)
{
int p,i,nWord;
//caculate the number of words in the packet.
nWord=(nByte+1)/2+1;
//generate the value in each words.
p=nByte%2;
i=0;
if (p==1)
{
i++;
uPacket[0]=255*rand()/RAND_MAX;
}
while(i<(nWord-1))
{
uPacket[i]=65535*rand()/RAND_MAX;
i++;
}
uPacket[i]=0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?