文件纯c语言实现md5算法(Pure C language implementation of MD5 algorithm)

c md5  时间:2021-01-27  阅读:()

纯c语言实现md5算法Pure C language implementation of MD5algorithm

Here is the code

Baidu needs points. I upload an integral that doesn't needpoints.

/ / pure to delete this comment can be confused with.#include<stdio.h>

#define F (x, y, z) (( (x) & (y) ) | ( (~x) & (z)))

#define G (x, y, z) (( (x) & (z) ) | ( (y) & (~z)))

#def ine, H (x, y, z) ( (x) ^ (y) ^ (z))

#define I (x, y, z) ((y) ^ ( (x) | (~z)) )

/ / pure to delete this comment can be confused with.#define RL (x, y) (((x) , (y) ( | ) (x) "(32 - (y)) )) //x y leftshift

#def ine PP (x) (x<<24) | ((x<<8) &0xff0000) | ((x>>8) &0xff00)| (x>>24) / / x high and low swap, such as PP (aabbccdd)=ddccbbaa

#def ine, FF (a, B, C, D, x, s, AC) a = B + (RL ((a +F (B, C,d) + X + AC) , s) )

#def ine, GG (a, B, C, D, x, s, AC) a = B + (RL ((a +G (B, C,d) + X + AC) , s) )

#def ine, HH (a, B, C, D, x, s, AC) a = B + (RL ((a +H (B, C,d) + X + AC) , s) )

#def ine, I I (a, B, C, D, x, s, AC) a = B + (RL ((a + I (B, C,d) + X + AC) , s) )

Unsigned, A, C, D, a, B, B, C, D, I, len, f len[2] , x[16], , //itemporary variables, len file length, and flen[2] initial filelength of binary binary representation

Char filename[200] ; / / f ile name

FILE *fp;

/ / pure to delete this comment can be confused with.Void MD5 () {//MD5 core algorithm for the 64 round

A=A, b=B, c=C, d=D;

/**//* Round * 1

FF (a, B, C, D, x[, 0] , 7, 0xd76aa478) ; /**//* 1.

FF (D, a, B, C, x[, 1] , 12, 0xe8c7b756) ; /**//* 2.

FF (C, D, a, B, x[, 2] , 17, 0x242070db) ; /**//* 3.

FF (B, C, D, a, x[, 3] , 22, 0xc1bdceee) ; /**//* 4.FF (a, B, C, D, x[, 4] , 7, 0xf57c0faf) ; /**//* 5.FF (D, a, B, C, x[, 5] , 12, 0x4787c62a) ; /**//* 6.FF (C, D, a, B, x[, 6] , 17, 0xa8304613) ; /**//* 7.FF (B, C, D, a, x[, 7] , 22, 0xf d469501) ; /**//* 8.FF (a, B, C, D, x[, 8] , 7, 0x698098d8) ; /**//* 9.FF (D, a, B, C, x[, 9] , 12, 0x8b44f7af) ; /**//* 10.FF (C, D, a, B, x[10], 17, 0xffff5bb1) ; /**//* 11.FF (B, C, D, a, x[11], 22, 0x895cd7be) ; /**//* 12.FF (a, B, C, D, x[12], 7, 0x6b901122) ; /**//* 13.FF (D, a, B, C, x[13], 12, 0xfd987193) ; /**//* 14.FF (C, D, a, B, x[14], 17, 0xa679438e) ; /**//* 15.FF (B, C, D, a, x[15], 22, 0x49b40821) ; /**//* 16./**//* Round * 2

GG (a, B, C, D, x[, 1] , 5, 0xf61e2562) ; /**//* 17.

GG (D, a, B, C, x[, 6] , 9, 0xc040b340) ; /**//* 18.GG (C, D, a, B, x[11], 14, 0x265e5a51) ; /**//* 19.GG (B, C, D, a, x[, 0] , 20, 0xe9b6c7aa) ; /**//* 20.GG (a, B, C, D, x[, 5] , 5, 0xd62f105d) ; /**//* 21.GG (D, a, B, C, x[10], 9, 0x02441453) ; /**//* 22.GG (C, D, a, B, x[15], 14, 0xd8a1e681) ; /**//* 23.GG (B, C, D, a, x[, 4] , 20, 0xe7d3fbc8) ; /**//* 24.GG (a, B, C, D, x[, 9] , 5, 0x21e1cde6) ; /**//* 25.GG (D, a, B, C, x[14], 9, 0xc33707d6) ; /**//* 26.GG (C, D, a, B, x[, 3] , 14, 0xf4d50d87) ; /**//* 27.GG (B, C, D, a, x[, 8] , 20, 0x455a14ed) ; /**//* 28.GG (a, B, C, D, x[13], 5, 0xa9e3e905) ; /**//* 29.GG (D, a, B, C, x[, 2] , 9, 0xfcefa3f8) ; /**//* 30.GG (C, D, a, B, x[, 7] , 14, 0x676f02d9) ; /**//* 31.GG (B, C, D, a, x[12], 20, 0x8d2a4c8a) ; /**//* 32./**//* Round * 3

HH (a, B, C, D, x[, 5] , 4, 0xfffa3942) ; /**//* 33.

Hh (D, a, B, C, X [8], 11, 0x8771f681) ; / * * / / * 34 * /Hh (C, D, a, B, X [11] , 16, 0x6d9d6122) ; / * * / / * 35 * /Hh (B, C, D, a, x] [14, 23, 0xfde5380c) ; / * * / / * 36 * /Hh (A, B, C, D, X [1], 4, 0xa4beea44) ; / * * / / * * / 37Hh (D, a, B, C, X [4], 11, 0x4bdecfa9) ; / * * / / * 38 * /Hh (C, D, a, B, X [7], 16, 0xf6bb4b60) ; / * * / / * * / 39Hh (B, C, D, a, X [10] , 23, 0xbebfbc70) ; / * * / / * 40 * /Hh (A, B, C, D, X [13] , 4, 0x289b7ec6) ; / * * / / * * / 41Hh (D, a, B, C, X [0], 11, 0xeaa127fa) ; / * * / / * * / 42Hh (C, D, a, B, X [3], 16, 0xd4ef3085) ; / * * / / * * / 43Hh (B, C, D, a, x] [6, 23, 0x04881d05) ; / * * / / * * / 44Hh (A, B, C, D, X [9], 4, 0xd9d4d039) ; / * * / / * 45 * /Hh (D, a, B, C, X [11, 12], 0xe6db99e5) ; / * * / / * 46 * /Hh (C, D, a, B, x] [15, 16, 0x1fa27cf8) ; / * * / / * 47 * /

Hh (B, C, D, a, X [2], 23, 0xc4ac5665) ; / * * / / * * / 48/ /纯是为了混淆用,删除本注释即可

/ * * / / * * / 4 round

I I (A, B, C, D, X [0], 6, 0xf4292244) ; / * * / / * * / 49I I (D, a, B, C, x] [7, 10, 0x432aff97) ; / * * / / * 50 * /II (C, D, a, B, X [14] , 15, 0xab9423a7) ; / * * / / * * / 51(B, C, D, a, X [5], 21, 0xfc93a039) ; / * * / / * 52 * /II (A, B, C, D, X [12] , 6, 0x655b59c3) ; / * * / / * * /II (D, a, B, C, X [3], 10, 0x8f0ccc92) ; / * * / / * * / 54II (C, D, a, B, X [10] , 15, 0xffeff47d) ; / * * / / * 55 * /(B, C, D, a, X [1], 21, 0x85845dd1) ; / * * / / * * / 56II (A, B, C, D, X [8], 6, 0x6fa87e4f) ; / * * / / * * / 57II (D, a, B, C, X [15] , 10, 0xfe2ce6e0) ; / * * / / * * / 58I I (C, D, a, B, X [6], 15, 0xa3014314) ; / * * / / * * / 59(B, C, D, a, X [13] , 21, 0x4e0811a1) ; / * * / / * 60 * /II (A, B, C, D, X [4], 6, 0xf7537e82) ; / * * / / * * / 61

I I (D, a, B, C, X [10, 11], 0xbd3af235) ; / * * / / * 62 * /II (C, D, a, B, X [2], 15, 0x2ad7d2bb) ; / * * / / * * / 63(B, C, D, a, x] [9, 21, 0xeb86d391) ; / * * / / * * / 64A + = a;

B + = B;

C + = C;

D = D +;

/ /纯是为了混淆用,删除本注释即可

}

/ /纯是为了混淆用,删除本注释即可

/ /纯是为了混淆用,删除本注释即可

Main() {

While (1) {/ /纯是为了混淆用,删除本注释即可

Printf ("Input File") ;

Gets (f ilename) ; / /用get函数,避免scanf以空格分割数据,

If (filename [0] == strlen (34) fi lename (f ilename) - 1] = 0,strcpy (fi lename, f ilename + 1) ; / /支持文件拖曳,但会多出双引号,这里是处理多余的双引号

If ( ! Strcmp (fi lename, "Exit") exit (0) ; / /输入exit退出If ( ! (FP=fopen (filename, "rb"))) {printf ("can not open thisf ile! \ n ") ; } / /以二进制打开文件continue;

Fseek (FP, 0, Seek _ end) ; / /文件指针转到文件末尾

If ( (Len = ftell () (FP)) = = - 1) {printf ("Sorry! Can notcalculate which files larger than 2 GB. \ n ") ; fclose (FP) ;continue; } / / ftell函数返回long,最大为2gb,超出返回- 1Rewi nd (FP) ; / /文件指针复位到文件头

A=b =0x67452301, 0xefcdab89 0x98badcfe, c = D= 0x10325476;/ /初始化链接变量

FLEN [1] = len / 0x20000000; / / f len单位是b it

F LEN [0] = (L EN% 0x 20000000) * 8;

Memset (X, 0.64) ; / /初始化x数组为0

Fread (& X, 4. 16, FP) ; / /以4字节为一组,读取16组数据For (i = 0; I < Len / 64; I + +) {/ /循环运算直至文件结束MD5 () ;

Memset (x, 0.64) ;

F REA D (& X, 4. 16, F P) ;

}

( (char*) (x) [len%64] = 128; //文件结束补1,补0操作, 128二进制即10000000

If (len% 64 > 55) MD5 () , memset (x, 0.64) ;

Memcpy (x + 14, flen, 8) ; / /文件末尾加入原文件的bit长度MD5 () ;

Fclose (PF) ;

Printf ("MD5 Code:%08x%08x%08x%08x \ n", PP (PP) , (b) , (c)PP, PP (d) ) ; / /高低位逆反输出

}

/ /纯是为了混淆用,删除本注释即可

}

Digital-VM暑期全场六折优惠,8个机房

Digital-VM商家目前也在凑热闹的发布六月份的活动,他们家的机房蛮多的有提供8个数据中心,包括日本、洛杉矶、新加坡等。这次六月份的促销活动全场VPS主机六折优惠。Digital-VM商家还是有一点点特点的,有提供1Gbps和10Gbps带宽的VPS主机,如果有需要大带宽的VPS主机可以看看。第一、商家优惠码优惠码:June40全场主机六折优惠,不过仅可以月付、季付。第二、商家VPS主机套餐1...

修罗云50元/月起香港大宽带NAT VPS,香港沙田建站2核2G5M仅70元/月起

修罗云怎么样?修罗云是一家国内老牌商家,修罗云商家以销售NAT机器起家,国内的中转机相当不错,给的带宽都非常高,此前推荐的也都是国内NAT VPS机器。今天,云服务器网(www.yuntue.com)小编主要介绍一下修罗云的香港云服务器,适合建站,香港沙田cn2云服务器,2核2G,5M带宽仅70元/月起,同时香港香港大带宽NAT VPS低至50元/月起,性价比不错,可以尝试一下!点击进入:修罗云官...

pacificrack:超级秒杀,VPS低至$7.2/年,美国洛杉矶VPS,1Gbps带宽

pacificrack又追加了3款特价便宜vps搞促销,而且是直接7折优惠(一次性),低至年付7.2美元。这是本月第3波便宜vps了。熟悉pacificrack的知道机房是QN的洛杉矶,接入1Gbps带宽,KVM虚拟,纯SSD RAID10,自带一个IPv4。官方网站:https://pacificrack.com支持PayPal、支付宝等方式付款7折秒杀优惠码:R3UWUYF01T内存CPUSS...

c md5为你推荐
ddr2内存价格DDR2的4G内存条一般在什么价格?苹果x和xr哪个好苹果x,苹果xs,苹果xr,苹果xs max哪个更值得买?手机浏览器哪个好手机浏览器哪个好?手机浏览器哪个好用?电热水器和燃气热水器哪个好电热水器和燃气热水器哪个好?传奇类手游哪个好传奇哪个版本比较好玩 最好玩的传奇手游排行榜无纺布和熔喷布口罩哪个好医用 口罩里面是无纺布好还是过滤纸好dnf魔枪士转职哪个好魔枪转职哪个适合搬砖车险哪个好车险平安和人保哪个好?都有什么优点和缺点?360云查杀360安全卫士中的木马云查杀有用吗?360云盘关闭360百度云盘到底什么时候关闭
黑龙江域名注册 注册cn域名 lunarpages 息壤备案 国内php空间 500m空间 北京双线机房 国外代理服务器软件 php空间购买 hktv 免费网页申请 linux使用教程 卡巴斯基是免费的吗 中国域名 防cc攻击 lamp怎么读 服务器硬件配置 广东服务器托管 免备案jsp空间 开心online 更多