Created
December 2, 2015 04:01
-
-
Save yogonza524/437b98c4d68fd992d91f to your computer and use it in GitHub Desktop.
PostgreSQL - Funcion para encriptar una cadena de caracteres de forma segura
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
CREATE OR REPLACE FUNCTION public.encode(val character varying) | |
RETURNS character varying AS | |
$BODY$ | |
BEGIN | |
RETURN encode(digest(val, 'sha1'), 'hex')::character varying; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql VOLATILE | |
COST 100; | |
ALTER FUNCTION public.encode(character varying) | |
OWNER TO postgres; |
Ya me acordé:
create extension pgcrypto;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Para que funcione requiere instanciar una extensión. No me acuerdo cual.