2024-12-03 06:53:31 +01:00
|
|
|
CREATE FUNCTION public.password_hash(salt_hex char(32), pass bytea)
|
|
|
|
RETURNS char(96)
|
|
|
|
LANGUAGE plpgsql
|
|
|
|
AS
|
|
|
|
$$
|
2024-11-28 18:11:14 +01:00
|
|
|
BEGIN
|
2024-12-03 06:53:31 +01:00
|
|
|
RETURN (
|
|
|
|
SELECT
|
|
|
|
salt_hex ||
|
|
|
|
encode(
|
|
|
|
sha256(
|
|
|
|
decode(salt_hex, 'hex') || /* salt in binary */
|
|
|
|
pass /* password */
|
|
|
|
),
|
|
|
|
'hex'
|
|
|
|
)
|
|
|
|
);
|
2024-11-28 18:11:14 +01:00
|
|
|
END;
|
|
|
|
$$;
|