30 static const char *hex =
"0123456789abcdef";
34 for (q = 0, w = 0; q < 16; q++)
36 s[w++] = hex[(
b[q] >> 4) & 0x0F];
37 s[w++] = hex[
b[q] & 0x0F];
146 char *
buf,
const char **errstr)
148 size_t passwd_len = strlen(passwd);
151 char *crypt_buf =
malloc(passwd_len + salt_len + 1);
156 *errstr =
_(
"out of memory");
164 memcpy(crypt_buf, passwd, passwd_len);
165 memcpy(crypt_buf + passwd_len, salt, salt_len);
168 ret =
pg_md5_hash(crypt_buf, passwd_len + salt_len,
buf + 3, errstr);
int pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)
int pg_cryptohash_init(pg_cryptohash_ctx *ctx)
void pg_cryptohash_free(pg_cryptohash_ctx *ctx)
pg_cryptohash_ctx * pg_cryptohash_create(pg_cryptohash_type type)
int pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len)
const char * pg_cryptohash_error(pg_cryptohash_ctx *ctx)
#define MD5_DIGEST_LENGTH
bool pg_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, char *buf, const char **errstr)
bool pg_md5_hash(const void *buff, size_t len, char *hexsum, const char **errstr)
bool pg_md5_binary(const void *buff, size_t len, void *outbuf, const char **errstr)
static void bytesToHex(uint8 b[16], char *s)