<commit_before># API Documentation

All examples assumes `var otplib = require('otplib');` as the base.

## Methods


### Core - `otplib.core.METHOD`

#### `.hotp(secret, counter)` 
**HMAC based OTP**

  * `secret` (_**string**_) _user secret_
  * `counter` (_**integer**_)



#### `.totp(secret)`
**Time based OTP**

  * `secret` (_**string**_) _user secret_



#### `.secret.generate(length)` 
**Generate a random secret**

 * length (_**integer**_) [optional, default: _16_]


#### `.secret.removeSpaces(secret)`
**Removes all spaces from specified secret**

  * `secret` (_**string**_) _user secret_
  
#### `.secret.divideIntoSetsOf(num, secret)` 
**Divides a string into sets according to the specified number**

  * `num` (_**integer**_) _number of characters in a set_
  * `secret` (_**string**_) _user secret_


#### `.token.check(token, secret, type, counter)` 
**Simple checking method for token**

 * `token` (_**string**_) _user provided one time pass_
 * `secret` (_**string**_) _user secret_
 * `type` (_**string**_) _'hotp' or 'totp'_
 * `counter` (_**string**_) [optional] _required for hotp_ 



#### `.helpers.stringToHex(value)` 
**Converts String to Hex**

  * `value` (_**string**_)



#### `.helpers.hexToInt(hex)`
**Converts Hex into an Integer**

 * `hex` (_**string**_) _hexadecimal string_



#### `helpers.intToHex(number)` 
**Parse number into an Integer and convert to Hex**

 * `number` (_**string/integer**_) _parseInt(base 10) will be called on the number_



#### `helpers.pad(value, total)` 
**Do a left padding of the value based on the total**

 * `value` (_**string**_) _string to pad_
 * `total` (_**string**_) _total number of characters in string_




## GoogleAuthenticator - `otplib.google.METHOD`

### `debug(status)` 
**Sets debug message printouts**

 * `status` (_**boolean**_) _true/false_



#### `secret(length)` 
**Generate a secret**

 * length (_**integer**_) [optional, default: _16_] 



#### `keyuri(user, service, secret)` 
**otpauth://totp/service:user?secret=NKEIBAOUFA&issuer=service_**


 * `user` (_**string**_) _eg. joe@localhost_
 * `service` (_**string**_) _eg. MyService_
 * `secret` (_**string**_) _user secret_


`qrcode(user, service, secret)` 
**Generates a QR Code image using Google Charts**

 * `user` (_**string**_) _eg. joe@localhost_
 * `service` (_**string**_) _eg. MyService_
 * `secret` (_**string**_) _user secret_



#### `generate(secret)` 
**Generate One Time Pass**


 * `secret` (_**string**_) _user secret_



#### `check(token, secret)` 
**Check for token validity**

 * `token` (_**string**_) _user provided one time pass_
 * `secret` (_**string**_) _user secret_



#### `encode(secret, type)` 
**Base32 encoding**

 * `secret` (_**string**_) _user secret_
 * `type` (_**string**_) [optional, default: _binary_] _encoding: binary, utf8, ascii_



#### `decode(secret, type)` 
**Base32 decoding**

 * `secret` (_**string**_) _user secret_
 * `type` (_**string**_) [optional, default: _binary_] _encoding: binary, utf8, ascii_ 
<commit_msg>API Doc update<commit_after># API Documentation

All examples assumes `var otplib = require('otplib');` as the base.


<div style="margin-top:6em;"></div>

### `otplib.core.METHOD` - Core


--

HMAC based OTP

#### `.hotp(secret, counter)` 

  * `secret` (_**string**_) _user secret_
  * `counter` (_**integer**_) 
  
--

Time based OTP

#### `.totp(secret)`

  * `secret` (_**string**_) _user secret_

--

Generate a random secret

##### `.secret.generate(length)` 

 * length (_**integer**_) [optional, default: _16_]


--

Removes all spaces from specified secret

#### `.secret.removeSpaces(secret)`

  * `secret` (_**string**_) _user secret_

--
  
Divides a string into sets according to the specified number

#### `.secret.divideIntoSetsOf(num, secret)` 

  * `num` (_**integer**_) _number of characters in a set_
  * `secret` (_**string**_) _user secret_

-- 

Simple checking method for token

#### `.token.check(token, secret, type, counter)` 


 * `token` (_**string**_) _user provided one time pass_
 * `secret` (_**string**_) _user secret_
 * `type` (_**string**_) _'hotp' or 'totp'_
 * `counter` (_**string**_) [optional] _required for hotp_ 

--

Converts String to Hex

#### `.helpers.stringToHex(value)` 

  * `value` (_**string**_)

--

Converts Hex into an Integer

#### `.helpers.hexToInt(hex)`

 * `hex` (_**string**_) _hexadecimal string_

--

Parse number into an Integer and convert to Hex

#### `helpers.intToHex(number)` 

 * `number` (_**string/integer**_) _parseInt(base 10) will be called on the number_

--

Do a left padding of the value based on the total

#### `helpers.pad(value, total)` 

 * `value` (_**string**_) _string to pad_
 * `total` (_**string**_) _total number of characters in string_

--

<div style="margin-top:6em;"></div>

### `otplib.google.METHOD` - Google Authenticator 
--

Sets debug message printouts

### `debug(status)` 

 * `status` (_**boolean**_) _true/false_

--

Generate a secret

#### `secret(length)` 

 * length (_**integer**_) [optional, default: _16_] 


--

otpauth://totp/service:user?secret=NKEIBAOUFA&issuer=service

#### `keyuri(user, service, secret)` 

 * `user` (_**string**_) _eg. joe@localhost_
 * `service` (_**string**_) _eg. MyService_
 * `secret` (_**string**_) _user secret_

--

Generates a QR Code image using Google Charts

`qrcode(user, service, secret)` 

 * `user` (_**string**_) _eg. joe@localhost_
 * `service` (_**string**_) _eg. MyService_
 * `secret` (_**string**_) _user secret_


--

Generate One Time Pass

#### `generate(secret)` 

 * `secret` (_**string**_) _user secret_


--

Check for token validity

#### `check(token, secret)` 

 * `token` (_**string**_) _user provided one time pass_
 * `secret` (_**string**_) _user secret_


--

Base32 encoding

#### `encode(secret, type)` 

 * `secret` (_**string**_) _user secret_
 * `type` (_**string**_) [optional, default: _binary_] _encoding: binary, utf8, ascii_

-- 

Base32 decoding

#### `decode(secret, type)` 

 * `secret` (_**string**_) _user secret_
 * `type` (_**string**_) [optional, default: _binary_] _encoding: binary, utf8, ascii_ 

{'fraction_non_alphanumeric': 0.19147198170233623, 'fraction_numerical': 0.004247671949027937, 'mean_word_length': 4.560399636693915, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5656325', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2097, 'n_words': 588}