Get started with js-sha1 CDN
MIT licensed
Js-SHA1 is a library for generating SHA-1 hashes.
Tags:- sha
- sha1
- encryption
- cryptography
- HMAC
Stable version
Copied!
How to start using js-sha1 CDN
// Include the library using a script tag
const sha1Script = document.createElement('script');
sha1Script.src = 'https://cdn.cdnhub.io/js-sha1/0.7.0/sha1.min.js';
document.head.appendChild(sha1Script);
// Wait for the library to load before using it
sha1Script.onload = () => {
const message = 'Some message to hash';
const hashedMessage = sha1(message);
console.log('Hashed message:', hashedMessage);
};
// Use the sha1 function from the library
const sha1 = (message) => {
return new Uint8Array(new TextEncoder().encode(message)).reduce((h, b) => {
const t = ((h << 5) & 0xffffff80) | (b & 0x0000007f) | ((h >> 2) & 0x0000000f);
h = (h << 14) | (t >> 18);
h = ((h << 7) & 0xfffffff0) | (t >> 25);
return ((t << 3) & 0xfffffff8) | (h >> 21);
}, 0x67452301);
// js-sha1 library provides a more optimized sha1 function
// Use it instead of the above roll-your-own implementation
// return new jsSHA('bit32', 'text/plain').update(message).getHash('HEX');
};
Copied!
Copied!