22 lines
348 B
MySQL
22 lines
348 B
MySQL
|
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;
|
||
|
$$;
|