Notes2/sql/00022.sql

22 lines
348 B
MySQL
Raw Normal View History

2024-11-29 09:15:42 +01:00
CREATE EXTENSION IF NOT EXISTS pgcrypto;
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;
$$;