20 lines
306 B
PL/PgSQL
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;
|
|
$$;
|