修改md5文件变量类型重定义

This commit is contained in:
lyq 2026-01-13 15:16:58 +08:00
parent a115de4977
commit 3568ef7ff9

View File

@ -5,7 +5,7 @@
#include <fstream> #include <fstream>
/* Type define */ /* Type define */
typedef unsigned char byte; typedef unsigned char MD5_byte;
typedef unsigned int uint32; typedef unsigned int uint32;
using std::ifstream; using std::ifstream;
@ -22,17 +22,17 @@ public:
void update(const void *input, size_t length); void update(const void *input, size_t length);
void update(const string &str); void update(const string &str);
void update(ifstream &in); void update(ifstream &in);
const byte *digest(); const MD5_byte *digest();
string toString(); string toString();
void reset(); void reset();
private: private:
void update(const byte *input, size_t length); void update(const MD5_byte *input, size_t length);
void final(); void final();
void transform(const byte block[64]); void transform(const MD5_byte block[64]);
void encode(const uint32 *input, byte *output, size_t length); void encode(const uint32 *input, MD5_byte *output, size_t length);
void decode(const byte *input, uint32 *output, size_t length); void decode(const MD5_byte *input, uint32 *output, size_t length);
string bytesToHexString(const byte *input, size_t length); string bytesToHexString(const MD5_byte *input, size_t length);
/* class uncopyable */ /* class uncopyable */
MD5(const MD5 &); MD5(const MD5 &);
@ -41,11 +41,11 @@ private:
private: private:
uint32 _state[4]; /* state (ABCD) */ uint32 _state[4]; /* state (ABCD) */
uint32 _count[2]; /* number of bits, modulo 2^64 (low-order word first) */ uint32 _count[2]; /* number of bits, modulo 2^64 (low-order word first) */
byte _buffer[64]; /* input buffer */ MD5_byte _buffer[64]; /* input buffer */
byte _digest[16]; /* message digest */ MD5_byte _digest[16]; /* message digest */
bool _finished; /* calculate finished ? */ bool _finished; /* calculate finished ? */
static const byte PADDING[64]; /* padding for calculate */ static const MD5_byte PADDING[64]; /* padding for calculate */
static const char HEX[16]; static const char HEX[16];
enum enum
{ {