digest
suggest changedigest() is provided by the pgcrypto extension (CREATE EXTENSION pgcrypto). It returns a binary hash of the given data. The hash is deterministic: the same input and algorithm always produce the same bytea. It is not a random generator. The second example varies the input with random() and the clock.
Usage: digest(data text, type text) returns bytea
Or: digest(data bytea, type text) returns bytea
Examples:
SELECT DIGEST('1', 'sha1')SELECT DIGEST(CONCAT(CAST(current_timestamp AS TEXT), RANDOM()::TEXT), 'sha1')
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents