Cryptographic algorithms –
Pure JavaScript implementations for:
- RFC 3174 - SHA-1 - Secure Hash Algorithm 1
- FIPS 180-2 - SHA-256 - Secure Hash Algorithm 2
- RFC 3874 - SHA-224 - A 224-bit One-way Hash Function
- RFC 2104 - HMAC - Keyed-Hashing for Message Authentication
- RFC 8018 - PBKDF2 - Password-Based Key Derivation Function 2
- RFC 6238 - TOTP - Time-Based One-Time Password
- RFC 4226 - HOTP - HMAC-Based One-Time Password
How to use in browser
<script src=crypto-lite.js></script>
<script>
crypto.sha1("secret")
crypto.sha256("secret")
crypto.hmac("sha1", "key", "message")
crypto.hmac("sha256", "key", "message")
crypto.pbkdf2("password", "salt", 1, 20, "sha1")
crypto.hotp("secret", { counter: 1, digits 6, algo: "sha1" })
crypto.totp("secret", { time: Date.now(), t0: 0, step: 30, digits 6, algo: "sha1" })
</script>
How to use in node.js
Although it should work in node.js,
you should use native api there.
npm install crypto-lite
var crypto = require("crypto-lite").crypto
External links
Licence
Copyright (c) 2014-2021 Lauri Rooden <lauri@rooden.ee>
The MIT License