Skip to main content

Module work

Module work 

Source
Expand description

Proof of Work and content hashing — Gun.js sea/work.js equivalent.

Provides two modes of cryptographic hashing:

  • PBKDF2 mode (default): Key derivation using PBKDF2-HMAC-SHA256 with 100,000 iterations and a random 9-byte salt (matching Gun.js). Used for password hashing and key derivation.

  • SHA-256 mode: Direct SHA-256 hash of input data. Triggered when WorkOptions::name starts with "sha" (case-insensitive).

§Blocking

PBKDF2 is CPU-intensive and runs via tokio::task::spawn_blocking.

§Example

use beam::sea::{work, WorkOptions};

let hash = work(b"password", None, WorkOptions::default()).await.unwrap();
assert!(!hash.is_empty());

Functions§

work
Compute proof-of-work or content hash.