@cryptography/sha1

中文文档
0.2.0发布于 2020/04/09GPL-3.0-or-laterTypeScriptESM + CJS零依赖近 30 天下载 1.3万

High-performance synchronous SHA-1 implementation for JavaScript

原始使用文档
文档目录8 节
  1. Features
  2. Setup
  3. When you should use @cryptography/sha1
  4. ⚠️ When you should not use this (WebCrypto API preferred ca…
  5. Usage
  6. Benchmarks
  7. Try yourself
  8. Contributing

@cryptography/sha256

Bundlephobia Coverage Travis CI

High-performance synchronous SHA-1 implementation for JavaScript. Optimized for browsers.

Features

  • Blazing fast
  • Ultra lightweight
  • ECMAScript 3-6
  • Typed
  • Tested`

Setup

Package is available through npm and yarn

npm install @cryptography/sha1
yarn add @cryptography/sha1

When you should use @cryptography/sha1

  • Hashing small inputs (< 5kb)
  • Key derivation functions
  • 100% browser support required

⚠️ When you should not use this (WebCrypto API preferred cases)

  • Hashing files (> 5kb)
  • Concurrent hashing large amount of messages

Usage

This package is optimized for small byte inputs (<10kb).

Also, it is highly recommended to run CPU-intensive tasks in a Web Worker.

import sha1 from '@cryptography/sha1'

// as Uint32Array([0xa8d627d9, 0x3f518e90, 0x96b6f40e, 0x36d27b76, 0x60fa26d3])
const array = sha1('Hello World!') 

// as hex-string: "a8d627d93f518e9096b6f4...."
const hex = sha1('Hello World!', 'hex')

// as binary string: "ÄïükYo‡UH½LÛ,Zß..."
const raw = sha1('Hello World!', 'binary')

// UInt32Array as input
const buf = new Uint32Array([0xa8d627d9, 0x3f518e90, 0x96b6f40e, 0x36d27b76, 0x60fa26d3, 0x18ef1adc, 0x43da750e, 0x49ebe4be]);
sha1(buf)

For hashing large files or other data chuncks use stream() to create a hashing stream.

sha1.stream().update('Hello World!').digest();

Benchmarks

Faster than forge, sjcl, Rusha and WebCrypto API in sequence mode.

Try yourself

Contributing

Contributions are welcome! Contribution guidelines will be published soon.

版本与发布记录

@cryptography/sha1 共发布 2 个版本,首次发布于 2019/12/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.0latest2020/04/096 年前
0.1.02019/12/046 年前

关于 @cryptography/sha1 的常见问题

@cryptography/sha1 是什么?

High-performance synchronous SHA-1 implementation for JavaScript

如何安装 @cryptography/sha1?

在项目目录运行 npm install @cryptography/sha1,或使用 pnpm add / yarn add / bun add。

@cryptography/sha1 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cryptography/sha1 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cryptography/sha1 可以商用吗?

@cryptography/sha1 使用 GPL-3.0-or-later 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@cryptography/sha1 的下载量有多少?

根据 npm 官方下载统计,@cryptography/sha1 在 2026/10/11 – 2026/11/09 这 30 天内被下载 13,330 次,日均约 444 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cryptography/sha1 还在维护吗?

最新版本 0.2.0 发布于 2020/04/09(6 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/12/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。