Skip to content

Instantly share code, notes, and snippets.

@ianthrive
Last active August 29, 2015 14:20
Show Gist options
  • Save ianthrive/61017e604cf1bd07774c to your computer and use it in GitHub Desktop.
Save ianthrive/61017e604cf1bd07774c to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION public.random_md5() RETURNS text LANGUAGE sql
AS $$ SELECT md5(gen_random_bytes(1024)); $$;
CREATE OR REPLACE FUNCTION public.sha256(subject bytea) RETURNS text LANGUAGE sql
AS $function$ SELECT ENCODE(DIGEST($1, 'sha256'), 'hex'); $function$
CREATE OR REPLACE FUNCTION public.random_sha256() RETURNS text LANGUAGE sql
AS $$ SELECT sha256(gen_random_bytes(1024)); $$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment