下载此文档

DES加密解密算法.docx


文档分类:IT计算机 | 页数:约34页 举报非法文档有奖
1/34
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/34 下载此文档
文档列表 文档介绍
//   
#ifndef BZF_MD5_H  
#define BZF_MD5_H  
  
#include <string>  
#include <iostream>  
  
  
// a small class for calculating MD5 hashes of strings or byte arrays  
// it is not meant to be fast or secure  
//  
// usage: 1) feed it blocks of uchars with update()  
//      2) finalize()  
//      3) get hexdigest() string  
//      or  
//      MD5(std::string).hexdigest()  
//  
// assumes that char is 8 bit and int is 32 bit  
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, uin

DES加密解密算法 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数34
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xunlai783
  • 文件大小67 KB
  • 时间2017-12-29