Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 778 Bytes

README.md

File metadata and controls

43 lines (31 loc) · 778 Bytes

otp

Description

Implementation of TOTP which is compatible with google authenticator app.

Usage

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]';

Author

Marcel Asio

Copyright and License

Copyright (c) 2015 Marcel Asio.