搜尋套件、儲存庫與 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

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單