搜索插件、代码仓与 APP 分类

插件详情v0.1.0

serverpod_argon2

Argon2 密码哈希(argon2id、argon2i、argon2d),基于 Zig 标准库。提供预构建的 Dart 和 Flutter 原生库以及 WebAssembly 模块以支持 Web,无需本地工具链...

AndroidiOSLinuxmacOSWebWindows
近 30 天下载
14.9万
喜欢数
3
Pub 分数
140

安装插件

flutter pub add serverpod_argon2

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个用于使用 Argon2 算法(argon2id、argon2i、argon2d)进行安全密码哈希的 Flutter/Dart 包。基于 Zig 标准库构建,提供适用于 Android、iOS、Linux、macOS、Windows 的预构建原生二进制文件,以及适用于 Web 环境的 WebAssembly 模块。这确保了高性能和安全性,无需本地工具链。适用于需要强大密码存储和身份验证的应用程序。

适合场景

  • 安全密码存储
  • 用户身份验证系统
  • 符合安全标准
  • 移动和Web应用中的密码哈希
  • 保护敏感的用户凭据

主要特点

  • 支持所有 Argon2 变体
  • 适用于所有平台的预构建原生库
  • WebAssembly 对 Web 的支持
  • 无需本地工具链
  • 高性能和安全性

适合对象

  • 处理用户密码的应用程序
  • 注重安全的后端服务
  • 跨平台 Flutter 应用
  • 需要强密码哈希的系统
  • 注重快速设置的开发者

使用建议

  • 需要 Dart 3.0 或更高版本
  • 仅限 Argon2 哈希
  • 依赖外部基于 Zig 的原生代码
  • 由于原生二进制文件,可能会略微增加应用大小
  • 不适用于非密码哈希用例

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

serverpod_argon2

Argon2 password hashing for Dart and Flutter, backed by the Argon2 implementation in the Zig standard library.

  • Native platforms load a prebuilt shared library through build hooks (native assets).
  • The web loads the same code compiled to WebAssembly, embedded in the package. This works with both dart2js and dart2wasm.
  • No toolchain is needed. Prebuilt libraries ship in the package for every supported target.

Usage

import 'package:serverpod_argon2/serverpod_argon2.dart';

final argon2 = await Argon2.load();

// $argon2id$v=19$m=19456,t=2,p=1$<salt>$<hash>
final encoded = argon2.hash('correct horse battery staple');

final ok = argon2.verify('correct horse battery staple', encoded);

hash defaults to Argon2Parameters.owasp (argon2id, 19 MiB, 2 iterations) and a random 16 byte salt. verify accepts PHC strings from any Argon2 implementation, as long as they use version 19. deriveKey returns raw bytes and takes the optional RFC 9106 secret and associatedData inputs.

Hashing runs on the calling thread and is slow by design. On native platforms, move it off the main isolate:

final encoded = await Isolate.run(() => argon2.hash(password));
Parallelism

The library is built single-threaded, so the p lanes are computed one after another. Hashes with p > 1 are still correct and compatible with other implementations, but take p times longer than a multithreaded implementation would. For more throughput, hash on several isolates.

Supported targets

OS Architectures
macOS arm64 (11.0+), x64 (10.15+)
iOS arm64 (13.0+), arm64 and x64 simulators
Android arm64, arm, x64
Linux x64, arm64, arm, riscv64
Windows x64, arm64
Web Any browser with WebAssembly

The libraries are pure Zig and link no libc. On Linux they run on any glibc or musl distribution.

Performance

benchmark/argon2_benchmark.dart compares against the pure Dart implementations in pointycastle and cryptography, after checking all three produce identical output. The file header shows how to run it in each mode. Results on an Intel Mac, argon2id with OWASP parameters, in ms per hash:

Implementation Dart JIT Dart AOT JavaScript (Node)
serverpod_argon2 43 46 40
cryptography 200 183 647
pointycastle 307 274 5996

Developing

A git checkout has no prebuilt libraries, so the build hook compiles from source. That needs the zig version in build.zig.zon (minimum_zig_version), either installed directly or through anyzig.

  • zig build test runs the RFC 9106 vectors against the Zig code.
  • dart test -p vm,chrome runs the Dart tests natively and in the browser.

Publishing

See PUBLISH.md.

所属分类

依赖

依赖清单 2 项

  • code_assets>=1.2.1 <3.0.0
  • hooks^2.0.0

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单