Notes2/sql/00002.sql
Magnus Åhall ac8b334eee Rewrite
2024-12-03 06:53:31 +01:00

20 lines
306 B
PL/PgSQL

CREATE FUNCTION public.password_hash(salt_hex char(32), pass bytea)
RETURNS char(96)
LANGUAGE plpgsql
AS
$$
BEGIN
RETURN (
SELECT
salt_hex ||
encode(
sha256(
decode(salt_hex, 'hex') || /* salt in binary */
pass /* password */
),
'hex'
)
);
END;
$$;