db/schema/0014_hashed_text.sql
Orion Kindel 56957d380a
Some checks failed
migrate-devel / migrate-devel (push) Failing after 7s
migrate-stage / migrate-stage (push) Failing after 8s
feat: permissions
2023-07-14 21:13:33 -04:00

22 lines
453 B
PL/PgSQL

select create_newtype_text('public.hashed_text');
create function hash_text(plain text)
returns hashed_text
language plpgsql
immutable
as $$
begin
return hashed_text_of_string(crypt(plain, gen_salt('bf')));
end;
$$;
create function hashed_text_matches(plain text, hashed hashed_text)
returns boolean
language plpgsql
immutable
as $$
begin
return hashed_text_to_string(hashed) = crypt(plain, hashed_text_to_string(hashed));
end;
$$;