add TOTP algorithm scripts.

This commit is contained in:
NobyDa 2021-07-29 16:26:13 +08:00
parent bcdd05a2df
commit 9b55c06e13
No known key found for this signature in database
GPG Key ID: E6B0AC788D373C5B
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,23 @@
## Desc
A time-based one-time password algorithm(TOTP), implemented entirely 100% in Javascript.
This script complies with [RFC6238](https://datatracker.ietf.org/doc/html/rfc6238) specification and can be run in Surge, QuantumultX, Loon, Shadowrocket.
## Usage
```javascript
const key = 'YOURCLIENTTOKEN'; //TOTP key
const totp = TOTP(key); //Return a six-digit one-time password.
console.log(totp); //Print log
```
## Acknowledgements
This script is adapted from https://jsfiddle.net/russau/rbyjk774 and uses Brian Turek's [jsSHA](https://github.com/caligatio/jsSHA/).

File diff suppressed because one or more lines are too long