# @aeternity/argon2-browser 中文文档

规范地址：https://npmcn.com/package/%40aeternity/argon2-browser/

版本：0\.1\.2
npm 元数据更新时间：2026-10-21T13:52:25.299Z
中文译文更新时间：2026-11-06T08:19:45.100Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40aeternity/argon2-browser
原文对照：https://npmcn.com/package/%40aeternity/argon2-browser/?lang=original
项目主页：https://github.com/aeternity/argon2-browser#readme
源码仓库：https://github.com/aeternity/argon2-browser

弃用说明：This package is no longer maintained

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：138 kB，9 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2022-02-07T06:25:19.581Z
- 最新版本发布：2022-02-12T06:46:12.831Z
- 近 30 天下载量：3896（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

为浏览器运行时间编译了 Argon2 库

## 安装

```sh
npm install @aeternity/argon2-browser
```

也可以使用：`pnpm add @aeternity/argon2-browser`、`yarn add @aeternity/argon2-browser`、`bun add @aeternity/argon2-browser`

## README

# 浏览器中的 Argon2 ![Build](https://github.com/antelle/argon2-browser/workflows/Build/badge.svg)

Argon2是密码捕捉功能,是密码捕捉竞赛的得主. 这里的Argon2库是为浏览器运行时间而编译的.

[现场演示](https://antelle.github.io/argon2-browser)

[更多关于 Argon2](https://github.com/P-H-C/phc-winner-argon2)

[使用量](https://npmcn.com/package/%40aeternity/argon2-browser/#readme-usage)

## 数字

|  | 时间,ms(更低) |
| --- | --- |
| 红色瓦斯姆 | 225 (韩语) |
| Chrome WASM+SIMD (英语) | 119国道 |
| Firefox 瓦斯姆语 | 195 (英语) |
| Firefox WASM+SIMD (火狐) 火狐WASM+SIMD | 135个 |
| 萨法里瓦斯姆 | 174国道 |
| 原生 - O3 SSE | 15个 |
| 原生 - O3 | 第42条 |
| 原生 - O1 | 第55条 |
| 原生 - O0 | 395个 |

## 测试环境

用于获取以上数字的环境:

算法参数( E)`-d -t 100 -m 10 -p 1`:

-   重复:100次
-   内存:1MiB(1024 KiB)
-   散列长度: 32
-   平行主义:1
-   rg2d

环境:

-   MacBook pro 2020, Intel Core i7, 2.3GHz (x64), macOS 10.14.6 (18G95) (英语)
-   Chrome 85.0.4183 (官方建筑)
-   Firefox 80.0.1 (英语)
-   萨法里 13.1.2 (15609.3.5.1.3)
-   已编译自 [https://github.com/P-H-C/phc-winner-argon2 (中文(简体) )](https://github.com/P-H-C/phc-winner-argon2) @ 440ceb9 (韩语)

## 代码大小

`ll -h dist`

| 文件 | 代码大小, kB |
| --- | --- |
| rg2.js | 页:1 |
| rg2号 | 第25条 |

## Argon2被修改了吗?

不,它使用的是上游的子模块.

## 锡默德

SIMD并不完全在WebAssembly, 但对于那些想尝试的人来说, 我们已经提供了一个工作建筑 与SIMD。 目前只在克罗姆工作, 要使用它,你需要添加 [此起源审判](https://developers.chrome.com/origintrials/#/view_trial/-4708513410415853567) 在你的网站上, 或启用 Chrome 旗帜中的 SIMD 特性.

更多关于V8的WebAssembly SIMD支持: [https://v8.dev/features/simd (英语)](https://v8.dev/features/simd)

在 Firefox 上, 您需要启用 `javascript.options.wasm_simd` 选项.

要使用 SIMD 版本, 装入 `argon2-simd.wasm` 改为 `argon2.wasm`。 。 。 .

## JS 图书馆

库可以从 npm 安装 :

```bash
npm install argon2-browser
```

然后将这个脚本添加到您的 HTML 或者使用您最喜欢的捆绑器 :

```html
<script src="node_modules/argon2-browser/dist/argon2.min.js"></script>
```

或者,可以使用捆绑的版本,这样可以只包含一个脚本:

```html
<script src="node_modules/argon2-browser/dist/argon2-bundled.min.js"></script>
```

计算散列 :

```javascript
argon2.hash({ pass: 'password', salt: 'somesalt' })
    .then(h => console.log(h.hash, h.hashHex, h.encoded))
    .catch(e => console.error(e.message, e.code))
```

验证编码的散列( 如果您需要的话) :

```javascript
argon2.verify({ pass: 'password', encoded: 'enc-hash' })
    .then(() => console.log('OK'))
    .catch(e => console.error(e.message, e.code))
```

其他参数:

```javascript
argon2.hash({
    // required
    pass: 'password',
    salt: 'salt',
    // optional
    time: 1, // the number of iterations
    mem: 1024, // used memory, in KiB
    hashLen: 24, // desired hash length
    parallelism: 1, // desired parallelism (it won't be computed in parallel, however)
    secret: new Uint8Array([...]), // optional secret data
    ad: new Uint8Array([...]), // optional associated data
    type: argon2.ArgonType.Argon2d, // Argon2d, Argon2i, Argon2id
})
// result
.then(res => {
    res.hash // hash as Uint8Array
    res.hashHex // hash as hex-string
    res.encoded // encoded hash, as required by argon2
})
// or error
.catch(err => {
    err.message // error message as string, if available
    err.code // numeric error code
})
```

```javascript
argon2.verify({
    // required
    pass: 'password',
    encoded: 'enc-hash',
    // optional
    secret: new Uint8Array([...]), // optional secret data
    ad: new Uint8Array([...]), // optional associated data
    type: argon2.ArgonType.Argon2d, // Argon2d, Argon2i, Argon2id. default: guess
})
// result
.then(res => {
    res.hash // hash as Uint8Array
    res.hashHex // hash as hex-string
    res.encoded // encoded hash, as required by argon2
})
// or error
.catch(err => {
    err.message // error message as string, if available
    err.code // numeric error code
})
```

## 使用量

您可以以几种方式使用此模块:

1.  例如,如果需要对内存进行更多的控制,则手动写出WASM加载器([实例](https://npmcn.com/package/%40aeternity/argon2-browser/docs/js/calc.js)(三);
2.  与 WebPack 或其他捆绑器捆绑([实例](https://npmcn.com/package/%40aeternity/argon2-browser/examples/webpack)(三);
3.  以香草为单位: [实例](https://npmcn.com/package/%40aeternity/argon2-browser/examples/vanilla)· ;
4.  在节点.js: [实例](https://npmcn.com/package/%40aeternity/argon2-browser/examples/node) (见下文注一).

## 炸弹

-   网络包 : [实例/网页包](https://github.com/antelle/argon2-browser/tree/master/examples/webpack)
-   创建- 反应- 应用程序 : [实例/反应](https://github.com/antelle/argon2-browser/tree/master/examples/react)。从 [38号](https://github.com/antelle/argon2-browser/issues/38#issuecomment-749690581)

## 节点.js 支持

当然 [可使用](https://npmcn.com/package/%40aeternity/argon2-browser/examples/node) 在节点.js中生成WASM,但是这不合理:通过将其编译为本土节点.js addon,你会得到更好的速度,这并非那么难. 等等,它已经做了,只是安装 [此软件包](https://github.com/ranisalt/node-argon2)。 。 。 .

## 它在什么地方用过吗?

没错! [基网](https://github.com/keeweb/keeweb) (网络密码管理器)正在使用它作为密码散列函数执行. [检查源代码](https://github.com/keeweb/keeweb/blob/develop/app/scripts/util/kdbxweb/kdbxweb-init.js#L11)如果你有兴趣的话.

## 大楼

你可以用它来建造一切

```bash
./build.sh
```

先决条件:

-   附有WebAssembly支持的标语([怎么样](http://webassembly.org/getting-started/developers-guide/)(中文(简体) )
-   计算

## 许可证

[麻省理工学院](https://opensource.org/licenses/MIT)

## 常见问题

### @aeternity/argon2-browser 是什么？

为浏览器运行时间编译了 Argon2 库注意：该包已被作者标记为弃用——This package is no longer maintained

### 如何安装 @aeternity/argon2-browser？

在项目目录运行 npm install @aeternity/argon2-browser，或使用 pnpm add / yarn add / bun add。

### @aeternity/argon2-browser 支持 TypeScript 吗？

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

### @aeternity/argon2-browser 支持 ESM 还是 CommonJS？

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

### @aeternity/argon2-browser 可以商用吗？

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

### @aeternity/argon2-browser 的下载量有多少？

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

### @aeternity/argon2-browser 还在维护吗？

最新版本 0\.1\.2 发布于 2022/02/12（4 年前）；至今共发布 3 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/02/07。作者已将其标记为弃用，新项目建议寻找替代方案。

