Last active
August 29, 2015 14:19
-
-
Save tym-xqo/6603748d32d20f8235db to your computer and use it in GitHub Desktop.
pgsql SHA-1 function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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