diff --git a/94501b7_to_047a51b.sql b/94501b7_to_047a51b.sql new file mode 100644 index 0000000..c809675 --- /dev/null +++ b/94501b7_to_047a51b.sql @@ -0,0 +1,34 @@ +create extension if not exists "pgcrypto" with schema "public" version '1.3'; + +set check_function_bodies = off; + +CREATE OR REPLACE FUNCTION public.hash_text(plain text) + RETURNS hashed_text + LANGUAGE plpgsql + IMMUTABLE +AS $function$ +begin + return row(crypt(plain, gen_salt('bf'))); +end; +$function$ +; + +CREATE OR REPLACE FUNCTION public.hashed_text_matches(plain text, hashed hashed_text) + RETURNS boolean + LANGUAGE plpgsql + IMMUTABLE +AS $function$ +begin + return hashed_text_string(hashed) = crypt(plain, hashed_text_string(hashed)); +end; +$function$ +; + +CREATE OR REPLACE FUNCTION public.hashed_text_string(hashed hashed_text) + RETURNS text + LANGUAGE sql + IMMUTABLE +AS $function$select (hashed.hashed);$function$ +; + +