Exemplo n.º 1
0
Arquivo: md5.c Projeto: 50wu/gpdb
bool
pg_md5_binary(const void *buff, size_t len, void *outbuf)
{
	if (!calculateDigestFromBuffer((uint8 *) buff, len, outbuf))
		return false;
	return true;
}
Exemplo n.º 2
0
Arquivo: md5.c Projeto: 50wu/gpdb
/*
 *	pg_md5_hash
 *
 *	Calculates the MD5 sum of the bytes in a buffer.
 *
 *	SYNOPSIS	  #include "md5.h"
 *				  int pg_md5_hash(const void *buff, size_t len, char *hexsum)
 *
 *	INPUT		  buff	  the buffer containing the bytes that you want
 *						  the MD5 sum of.
 *				  len	  number of bytes in the buffer.
 *
 *	OUTPUT		  hexsum  the MD5 sum as a '\0'-terminated string of
 *						  hexadecimal digits.  an MD5 sum is 16 bytes long.
 *						  each byte is represented by two heaxadecimal
 *						  characters.  you thus need to provide an array
 *						  of 33 characters, including the trailing '\0'.
 *
 *	RETURNS		  false on failure (out of memory for internal buffers) or
 *				  true on success.
 *
 *	STANDARDS	  MD5 is described in RFC 1321.
 *
 *	AUTHOR		  Sverre H. Huseby <*****@*****.**>
 *
 */
bool
pg_md5_hash(const void *buff, size_t len, char *hexsum)
{
	uint8		sum[16];

	if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
		return false;

	bytesToHex(sum, hexsum);
	return true;
}
Exemplo n.º 3
0
Arquivo: md5.c Projeto: heysion/1ghl
/*
 *	pool_md5_hash
 *
 *	Calculates the MD5 sum of the bytes in a buffer.
 *
 *	SYNOPSIS	  int md5_hash(const void *buff, size_t len, char *hexsum)
 *
 *	INPUT		  buff	  the buffer containing the bytes that you want
 *						  the MD5 sum of.
 *				  len	  number of bytes in the buffer.
 *
 *	OUTPUT		  hexsum  the MD5 sum as a '\0'-terminated string of
 *						  hexadecimal digits.  an MD5 sum is 16 bytes long.
 *						  each byte is represented by two heaxadecimal
 *						  characters.  you thus need to provide an array
 *						  of 33 characters, including the trailing '\0'.
 *
 *	RETURNS		  false on failure (out of memory for internal buffers) or
 *				  true on success.
 *
 *	STANDARDS	  MD5 is described in RFC 1321.
 *
 *	AUTHOR		  Sverre H. Huseby <*****@*****.**>
 *  MODIFIED by   Taiki Yamaguchi <*****@*****.**>
 *
 */
int
md5_hash(const void *buff, size_t len, char *hexsum)
{
    uint8		sum[16];

    if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
        return 0;				/* failed */

    bytesToHex(sum, hexsum);
    return 1;					/* success */
}