@aeternity/argon2-browser

中文文档
0.1.2发布于 2022/02/12MITCommonJS零依赖近 30 天下载 3896

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

此软件包已被标记为弃用

This package is no longer maintained

中文使用文档
文档目录12 节
  1. 数字
  2. 测试环境
  3. 代码大小
  4. Argon2被修改了吗?
  5. 锡默德
  6. JS 图书馆
  7. 使用量
  8. 炸弹
  9. 节点.js 支持
  10. 它在什么地方用过吗?
  11. 大楼
  12. 许可证

浏览器中的 Argon2 Build

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

现场演示

更多关于 Argon2

使用量

数字

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

测试环境

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

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

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

环境:

代码大小

ll -h dist

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

Argon2被修改了吗?

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

锡默德

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

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

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

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

JS 图书馆

库可以从 npm 安装 :

npm install argon2-browser

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

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

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

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

计算散列 :

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

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

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

其他参数:

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
})
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加载器(实例(三);
  2. 与 WebPack 或其他捆绑器捆绑(实例(三);
  3. 以香草为单位: 实例· ;
  4. 在节点.js: 实例 (见下文注一).

炸弹

节点.js 支持

当然 可使用 在节点.js中生成WASM,但是这不合理:通过将其编译为本土节点.js addon,你会得到更好的速度,这并非那么难. 等等,它已经做了,只是安装 此软件包。 。 。 .

它在什么地方用过吗?

没错! 基网 (网络密码管理器)正在使用它作为密码散列函数执行. 检查源代码如果你有兴趣的话.

大楼

你可以用它来建造一切

./build.sh

先决条件:

  • 附有WebAssembly支持的标语(怎么样(中文(简体) )
  • 计算

许可证

麻省理工学院

版本与发布记录

@aeternity/argon2-browser 共发布 3 个版本,首次发布于 2022/02/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.2latest2022/02/124 年前
0.1.12022/02/074 年前
0.1.02022/02/074 年前

关于 @aeternity/argon2-browser 的常见问题

@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。作者已将其标记为弃用,新项目建议寻找替代方案。