md5算法的c++实现

时间:2014-11-01 10:23:51
【文件属性】:
文件名称:md5算法的c++实现
文件大小:5KB
文件格式:RAR
更新时间:2014-11-01 10:23:51
C++ md5 看到一个不错的c++实现的md5算法 class MD5 { public: typedef unsigned int size_type; // must be 32bit MD5(); MD5(const std::string& text); void update(const unsigned char *buf, size_type length); void update(const char *buf, size_type length); MD5& finalize(); std::string hexdigest() const; friend std::ostream& operator<<(std::ostream&, MD5 md5); private: void init(); typedef unsigned char uint1; // 8bit typedef unsigned int uint4; // 32bit enum {blocksize = 64}; // VC6 won't eat a const static int here void transform(const uint1 block[blocksize]); static void decode(uint4 output[], const uint1 input[], size_type len); static void encode(uint1 output[], const uint4 input[], size_type len); bool finalized; uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk uint4 count[2]; // 64bit counter for number of bits (lo, hi) uint4 state[4]; // digest so far uint1 digest[16]; // the result // low level logic operations static inline uint4 F(uint4 x, uint4 y, uint4 z); static inline uint4 G(uint4 x, uint4 y, uint4 z); static inline uint4 H(uint4 x, uint4 y, uint4 z); static inline uint4 I(uint4 x, uint4 y, uint4 z); static inline uint4 rotate_left(uint4 x, int n); static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); }; std::string md5(const std::string &str);
【文件预览】:
md5.cpp
main.cpp
md5.h

网友评论

  • 还行吧 参考
  • 很实用的一段代码,在我的程序中用到了这段代码,在这儿表示感谢
  • 非常感谢,就是没有读取文件进行check的功能.不过自己加一个也不难
  • 这个是不错啊,加油
  • 能够使用,学习加密算法中。。。
  • 可以用,不错!
  • 还行,就是还需要自己修改
  • 可以直接用,但是VS2012下的项目需要把sprintf改成sprintf_s(,,3)
  • 很好用,正是我想要的版本
  • 资源不错,能用.
  • 不错,,贴上去就可以用
  • 程序执行没有问题,注释也很完备。就是没有信息输入的函数模块,只能加密文件中给出的,不过自己改一下就可以的。挺实用的,thank you
  • 非常好,给了我很大的帮助
  • 经实验,确实可用的。感谢!
  • 不错,有空要试一试,正好项目上有这个要求!