CC_MD53cc
Md2, md4, and md5 hash functions
Usage
#include <CommonCrypto/CommonDigest.h>
extern int
CC_MD2_Init(CC_MD2_CTX *c);
extern int
CC_MD2_Update(CC_MD2_CTX *c, const void *data, CC_LONG len);
extern int
CC_MD2_Final(unsigned char *md, CC_MD2_CTX *c);
extern unsigned char *
CC_MD2(const void *data, CC_LONG len, unsigned char *md);
extern int
CC_MD4_Init(CC_MD4_CTX *c);
extern int
CC_MD4_Update(CC_MD4_CTX *c, const void *data, CC_LONG len);
extern int
CC_MD4_Final(unsigned char *md, CC_MD4_CTX *c);
extern unsigned char *
CC_MD4(const void *data, CC_LONG len, unsigned char *md);
extern int
CC_MD5_Init(CC_MD5_CTX *c);
extern int
CC_MD5_Update(CC_MD5_CTX *c, const void *data, CC_LONG len);
extern int
CC_MD5_Final(unsigned char *md, CC_MD5_CTX *c);
extern unsigned char *
CC_MD5(const void *data, CC_LONG len, unsigned char *md);
Overview
The following functions are used to produce an hash from data:
CC_MD2_Init() initializes a CC_MD2_CTX structure.
CC_MD2_Update() can be called repeatedly with chunks of the message to be hashed (len bytes at data).
CC_MD2_Final() places the MD2 message digest in md, which must have space for CC_MD2_DIGEST_LENGTH == 16 bytes of output, and erases the CC_MD2_CTX.
CC_MD2() computes the MD2 message digest of the len bytes at data and places it in md (which must have space for CC_MD2_DIGEST_LENGTH == 16 bytes of output). It returns the md pointer.
CC_MD4_Init(), CC_MD4_Update(), CC_MD4_Final(), CC_MD4(), CC_MD5_Init(), CC_MD5_Update(), CC_MD5_Final(), and CC_MD5() are analogous using an CC_MD4_CTX and CC_MD5_CTX structure.
Note
MD2, MD4, and MD5 are recommended only for compatibility with existing applications. In new applications, SHA-256(or greater) should be preferred.
Return values
All routines return 1 upon success and NULL upon failure, except for the one-shot routines ( CC_MD2() , etc.), which return the pointer passed in via the md parameter.
Releases
115 releases since Mac OS X 10.5; the text changed 1 time.