A simple SHA1 hash function for JavaScript supports UTF-8 encoding.
Installations
npm install js-sha1
Developer Guide
Typescript
No
Module System
CommonJS, UMD
Node Version
14.17.1
NPM Version
6.14.13
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (95.49%)
HTML (4.51%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
emn178
Download Statistics
Total Downloads
22,301,719
Last Day
2,888
Last Week
2,888
Last Month
595,897
Last Year
7,781,577
GitHub Statistics
339 Stars
20 Commits
150 Forks
16 Watching
2 Branches
1 Contributors
Bundle Size
7.70 kB
Minified
2.63 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.7.0
Package Id
js-sha1@0.7.0
Unpacked Size
32.76 kB
Size
8.97 kB
File Count
7
NPM Version
6.14.13
Node Version
14.17.1
Publised On
24 Jan 2024
Total Downloads
Cumulative downloads
Total Downloads
22,301,719
Last day
0%
2,888
Compared to previous day
Last week
-97.8%
2,888
Compared to previous week
Last month
-0.4%
595,897
Compared to previous month
Last year
39.7%
7,781,577
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
js-sha1
A simple SHA1 hash function for JavaScript supports UTF-8 encoding.
Demo
SHA1 Online SHA1 File Checksum Online
Download
Installation
You can also install js-sha1 by using Bower.
bower install js-sha1
For node.js, you can use this command to install:
npm install js-sha1
Notice
NIST formally deprecated use of SHA-1 in 2011 and disallowed its use for digital signatures in 2013, and declared that it should be phased out by 2030. However, SHA-1 is still secure for HMAC. wiki
Usage
You could use like this:
1sha1('Message to hash'); 2var hash = sha1.create(); 3hash.update('Message to hash'); 4hash.hex(); 5 6// HMAC 7sha1.hmac('key', 'Message to hash'); 8 9var hash = sha1.hmac.create('key'); 10hash.update('Message to hash'); 11hash.hex();
Node.js
If you use node.js, you should require the module first:
1var sha1 = require('js-sha1');
TypeScript
If you use TypeScript, you can import like this:
1import { sha1 } from 'js-sha1';
RequireJS
It supports AMD:
1require(['your/path/sha1.js'], function(sha1) { 2// ... 3});
Example
1sha1(''); // da39a3ee5e6b4b0d3255bfef95601890afd80709 2sha1('The quick brown fox jumps over the lazy dog'); // 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 3sha1('The quick brown fox jumps over the lazy dog.'); // 408d94384216f890ff7a0c3528e8bed1e0b01621 4 5// It also supports UTF-8 encoding 6sha1('ä¸æ–‡'); // 7be2d2d20c106eee0836c9bc2b939890a78e8fb3 7 8// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` 9sha1([]); // da39a3ee5e6b4b0d3255bfef95601890afd80709 10sha1(new Uint8Array([])); // da39a3ee5e6b4b0d3255bfef95601890afd80709 11 12// Different output 13sha1(''); // da39a3ee5e6b4b0d3255bfef95601890afd80709 14sha1.hex(''); // da39a3ee5e6b4b0d3255bfef95601890afd80709 15sha1.array(''); // [218, 57, 163, 238, 94, 107, 75, 13, 50, 85, 191, 239, 149, 96, 24, 144, 175, 216, 7, 9] 16sha1.digest(''); // [218, 57, 163, 238, 94, 107, 75, 13, 50, 85, 191, 239, 149, 96, 24, 144, 175, 216, 7, 9] 17sha1.arrayBuffer(''); // ArrayBuffer 18 19// HMAC 20sha1.hmac.hex('key', 'Message to hash'); 21sha1.hmac.array('key', 'Message to hash'); 22// ...
License
The project is released under the MIT license.
Contact
The project's website is located at https://github.com/emn178/js-sha1
Author: Chen, Yi-Cyuan (emn178@gmail.com)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0
Reason
4 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-x3m3-4wpv-5vgc
Reason
Found 0/16 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Score
2.5
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More