@bitgo/blake2b-wasm

中文文档
3.2.3发布于 2023/08/05MITCommonJS近 30 天下载 40.3万

Blake2b implemented in WASM

原始使用文档
文档目录5 节
  1. Usage
  2. API
  3. Browser demo
  4. Contributing
  5. License

blake2b-wasm

Blake2b implemented in WASM

npm install @bitgo/blake2b-wasm

Works in browsers that support WASM and Node.js 8+.

Usage

var blake2b = require('@bitgo/blake2b-wasm');

if (!blake2b.SUPPORTED) {
  console.log('WebAssembly not supported by your runtime');
}

blake2b.ready(function (err) {
  if (err) throw err;

  var hash = blake2b()
    .update(Buffer.from('hello')) // pass in a buffer or uint8array
    .update(Buffer.from(' '))
    .update(Buffer.from('world'))
    .digest('hex');

  console.log('Blake2b hash of "hello world" is %s', hash);
});

API

var hash = blake2b([digestLength], [key], [salt], [personal])

Create a new hash instance. digestLength defaults to 32.

hash.update(data)

Update the hash with a new piece of data. data should be a buffer or uint8array.

var digest = hash.digest([enc])

Digest the hash.

var promise = blake2b.ready([cb])

Wait for the WASM code to load. Returns the WebAssembly instance promise as well for convenience. You have to call this at least once before instantiating the hash.

Browser demo

There is a browser example included in example.html and example.js.

Contributing

The bulk of this module is implemented in WebAssembly in the blake2b.wat file. The format of this file is S-Expressions that can be compiled to their binary WASM representation by doing

wat2wasm blake2b.wat -o blake2b.wasm

To build the thin JavaScript wrapper for the WASM module use wat2js:

# also available as `npm run compile`
wat2js blake2b.wat -o blake2b.js

If you do not have wat2wasm installed follow the instructions here, https://github.com/WebAssembly/wabt

License

MIT

版本与发布记录

@bitgo/blake2b-wasm 共发布 16 个版本,首次发布于 2021/04/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.2.3latest2023/08/053 年前
3.2.22023/07/293 年前
3.2.12023/07/193 年前
3.2.02022/10/194 年前
3.0.42022/10/014 年前
3.0.4-rc.0rc2022/07/274 年前

其他发布通道:dev → 3.1.0-dev.0,rc → 3.0.4-rc.0。

关于 @bitgo/blake2b-wasm 的常见问题

@bitgo/blake2b-wasm 是什么?

Blake2b implemented in WASM

如何安装 @bitgo/blake2b-wasm?

在项目目录运行 npm install @bitgo/blake2b-wasm,或使用 pnpm add / yarn add / bun add。

@bitgo/blake2b-wasm 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bitgo__blake2b-wasm 是否存在。

@bitgo/blake2b-wasm 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bitgo/blake2b-wasm 可以商用吗?

@bitgo/blake2b-wasm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bitgo/blake2b-wasm 的下载量有多少?

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

@bitgo/blake2b-wasm 还在维护吗?

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