Skip to content

Instantly share code, notes, and snippets.

@tym-xqo
Last active August 29, 2015 14:19
Show Gist options
  • Save tym-xqo/6603748d32d20f8235db to your computer and use it in GitHub Desktop.
Save tym-xqo/6603748d32d20f8235db to your computer and use it in GitHub Desktop.
pgsql SHA-1 function
BEGIN;
CREATE EXTENSION pgcrypto;
CREATE OR REPLACE FUNCTION sha1(text)
RETURNS character varying AS
$BODY$
BEGIN
RETURN ENCODE(public.DIGEST($1, 'sha1'), 'hex');
END;
$BODY$
LANGUAGE 'plpgsql'
;
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment