/* MD5 produces a 16 byte (128 bit) hash; double it for hex */ #define MD5_HASH_LEN 32
/* *CreateanMD5hashofatextvalueandreturnitashexstring.
*/
Datum
md5_text(PG_FUNCTION_ARGS)
{
text *in_text = PG_GETARG_TEXT_PP(0);
size_t len; char hexsum[MD5_HASH_LEN + 1]; constchar *errstr = NULL;
/* Calculate the length of the buffer using varlena metadata */
len = VARSIZE_ANY_EXHDR(in_text);
/* get the hash result */ if (pg_md5_hash(VARDATA_ANY(in_text), len, hexsum, &errstr) == false)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("could not compute %s hash: %s", "MD5",
errstr)));
/* convert to text and return it */
PG_RETURN_TEXT_P(cstring_to_text(hexsum));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.