Skip to content

HMAC-Based One-Time Password (HOTP) Algorithm

License

Notifications You must be signed in to change notification settings

quicksam/node-hotp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HOTP TOTP

npm npm license npm downloads build status

HMAC-Based One-Time Password (HOTP), and Time-Based One-Time Password (TOTP) Algorithms

Install via npm

$ npm install --save hotp

Usage

HOTP

hotp( key, counter[, options] )

  • key {Buffer|String}
  • counter {Buffer|String|Number}
  • options {Object}
    • algorithm {Number} Default: 'sha1'
    • digits {Number} Default: 6
  • Returns {String}

Example

var hotp = require( 'hotp' )

var key = 'a very secret key'
var counter = 0

var token = hotp( key, counter, { digits: 8 })

console.log( token ) // > '78035651'

TOTP

hotp.totp( key[, options] )

  • key {Buffer|String}
  • options {Object}
    • algorithm {Number} Default: 'sha1'
    • digits {Number} Default: 6
    • time {Number} Default: (Date.now() / 1000)
    • timeStep {Number} Default: 30
    • t0 {Number} Default: 0
  • Returns {String}

Example

var hotp = require( 'hotp' )

var key = 'a very secret key'
var token = hotp.totp( key, { digits: 8 })

console.log( token ) // > '86247382'

CLI Usage

hotp <key> <counter> [digits=6]
totp <key> [digits=6]

References

About

HMAC-Based One-Time Password (HOTP) Algorithm

Resources

License

Stars

Watchers

Forks

Packages

No packages published