#include "iostream"
#include "string"
#include "math.h"
using namespace std;
typedef char
byte;
//初始化四個數
long a=0x67452301l;
long b=0xefcdab89l;
long c=0x98badcfel;
long d=0x10325476l;
long f(long x, long y, long z)
long g(long x, long y, long z)
long h(long x, long y, long z)
long i(long x, long y, long z)
long ff(long
a, long b, long c, long d, long mj, long s, long ti)
long gg(long
a, long b, long c, long d, int mj, int s, int ti)
long hh(long
a, long b, long c, long d, int mj, int s, int ti)
long ii(long
a, long b, long c, long d, int mj, int s, int ti)
void loops(int group[16])
//根據迴圈後abcd的值得到md5碼
string ge***code();
string code = "";
long
a = a, b = b, c = c, d = d;
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
a=0x67452301l;
b=0xefcdab89l;
c=0x98badcfel;
d=0x10325476l;
return code;
} int bittounsign(int b)
//將64個位元組劃分成16組,每小組4個位元組
int* dividegroup(byte *bytes, int n)
return group;
} //根據輸入資訊來返回該資訊對應的md5碼
string md5(string s)
long grouplength = length / 64;
for (int i = 0; i < grouplength; i++)
int remain = length % 64;//剩餘的位元組
byte rest[128];
long bitlength = length
<< 3;//資訊總共有多少位
if (remain <=56)
if (remain < 56)
} for (int i = 56; i < 64; i++)
loops(dividegroup(rest, 0));
} else
for (int i = 120; i < 128; i++)
loops(dividegroup(rest, 0));
loops(dividegroup(rest, 64));
} //根據運算後的abcd返回其md5碼
return ge***code();
} int main(int argc, char * argcs)
MD5 使用C 語言實現
md5是一種訊息摘要演算法。include include include include include using namespace std typedef unsigned char uint8 typedef unsigned short uint16 typedef unsigned i...
MD5加密演算法C語言實現
include include include include include define block len 64 define max blocks 9 define message len block len max blocks 1 define result len 33 md5演算法的...
Hash(雜湊)演算法及MD5的C語言實現
什麼是雜湊演算法?雜湊演算法又叫雜湊演算法,是將任意長度的二進位制值對映為較短的固定長度的二進位制值,這個小的二進位制值稱為雜湊值。它的原理其實很簡單,就是把一段交易資訊轉換成乙個固定長度的字串。這串字串具有一些特點 1.資訊相同,字串也相同。2.資訊相似不會影響字串相同。3.可以生成無數的資訊,但...