Skip to content

Instantly share code, notes, and snippets.

@ufuk
Last active January 29, 2018 11:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ufuk/03ca06d1ab90a2eedb15ce7884ed754d to your computer and use it in GitHub Desktop.
Save ufuk/03ca06d1ab90a2eedb15ce7884ed754d to your computer and use it in GitHub Desktop.
Enable cryptography functions (pgcrypto extension) in PostgreSQL.
CREATE EXTENSION pgcrypto;
-- Examples
SELECT ENCODE(DIGEST('password', 'md5'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha1'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha224'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha256'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha384'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha512'), 'base64');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment