New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

hotp

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotp

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

latest
npmnpm
Version
3.0.1
Version published
Weekly downloads
266
-77.36%
Maintainers
0
Weekly downloads
 
Created
Source

HOTP TOTP

npm npm license npm downloads

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

Install via npm

$ npm install --save hotp

Changelog

  • v3.0.0: Removed CLI utilities – now to be found at jhermsmeier / hotp-totp-cli
  • v2.0.0: Added TOTP implementation
  • v1.0.0: Initial release

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'

References

Keywords

hotp

FAQs

Package last updated on 03 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts