Tôi đã tìm thấy một số mã md5 bao gồm các nguyên mẫu sau ...Làm thế nào để tạo một băm md5 của một chuỗi trong C?
Tôi đã cố gắng tìm ra nơi tôi phải đặt chuỗi tôi muốn băm, những chức năng nào tôi cần gọi và nơi để tìm chuỗi khi nó đã được băm. Tôi đang bối rối liên quan đến những gì uint32 buf [4] và uint32 bit [2] là trong cấu trúc.
struct MD5Context {
uint32 buf[4];
uint32 bits[2];
unsigned char in[64];
};
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void MD5Init(struct MD5Context *context);
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len);
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(unsigned char digest[16], struct MD5Context *context);
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(uint32 buf[4], uint32 const in[16]);
Nice nghĩ, trưng bày các chuyển đổi của các hash thành một chuỗi. – dmckee
Hmm, tôi nhận được 'lỗi: kích thước lưu trữ của‘ ngữ cảnh ’không được xác định’ Tôi bao gồm '#include ' –
@SSHTi tôi không tin rằng mã OPs đang sử dụng openssl. –