Implementation of TOTP which is compatible with google authenticator app.
CREATE EXTENSION otp;
CREATE TABLE users (
email text not null,
secret text not null,
interval int not null default 30,
length int not null default 6
);
INSERT INTO users (email, secret) VALUES ('[email protected]', random_base32());
SELECT generate_totp(secret, interval, length)
FROM users WHERE email = '[email protected]';
SELECT verify_totp(secret, interval, '380092')
FROM users
WHERE email = '[email protected]';
SELECT provisioning_url(email, secret, interval, 'Company Name')
FROM users
WHERE email = '[email protected]';
Marcel Asio
Copyright (c) 2015 Marcel Asio.