金山开源MD5加密算法c++版.docxVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
金山开源MD5加密算法c版

md5.h#ifndef MD5_H 02#define MD5_H 03??04#ifdef __cplusplus 05externC{ 06#endif 07??08typedefunsigned intword32; 09#define MD5_SIZE 16 10??11structMD5Context { 12????word32 buf[4]; 13????word32 bits[2]; 14????unsigned charin[64]; 15}; 16??17voidMD5Init(structMD5Context *context); 18voidMD5Update(structMD5Context *context, unsigned charconst*buf, 19???????????unsigned len); 20voidMD5Final(unsigned chardigest[16], structMD5Context *context); 21voidMD5Transform(word32 buf[4], word32 constin[16]); 22??23/** 24?* This is needed to make RSAREF happy on some MS-DOS compilers. 25?*/26typedefstructMD5Context MD5_CTX; 27??28char* crypt_md5(constchar* pw, constchar* salt); 29void_crypt_to64(char* s,unsigned longv, intn); 30??31#ifdef __cplusplus 32} 33#endif 34??35#endif /** !MD5_H */md5.c#include string.h 002#include md5.h 003??004#ifndef WORDS_BIGENDIAN 005#define byteReverse(buf, len)?? /** Nothing */ 006#else 007staticvoidbyteReverse(unsigned char*buf, unsigned longs); 008??009/** 010?* Note: this code is harmless on little-endian machines. 011?*/012staticvoidbyteReverse(unsigned char*buf, unsigned longs) 013{ 014????word32 t; 015????do{ 016????t = (word32) ((unsigned) buf[3] 8 | buf[2]) 16 | 017????????((unsigned) buf[1] 8 | buf[0]); 018????*(word32 *) buf = t; 019????buf += 4; 020????} while(--longs); 021} 022#endif 023??024/** 025?* Start MD5 accumulation.? Set bit count to 0 and buffer to mysterious 026?* initialization constants. 027?*/028voidMD5Init(structMD5Context *ctx) 029{ 030????ctx-buf[0] = 0 031????ctx-buf[1] = 0xefcdab89; 032????ctx-buf[2] = 0x98badcfe; 033????ctx-buf[3] = 0 034??035????ctx-bits[0] = 0; 036????ctx-bits[1] = 0; 037} 038??039/** 040?* Update context to reflect the concatenation of another buffer full 041?* of bytes. 042?*/043voidMD5Update(structMD5Context *ctx, unsigned charconst*buf, unsigned len) 044{ 045????registerword32 t; 046??047????/** Update bitcount */048??049????t = ctx-bits[0]; 050????if((ctx-bits[0] = t + ((w

文档评论(0)

haocen + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档