pub async fn work(
data: &[u8],
salt: Option<&[u8]>,
opts: WorkOptions,
) -> Result<String, SeaError>Expand description
Compute proof-of-work or content hash.
§PBKDF2 Mode (default)
- Algorithm: PBKDF2-HMAC-SHA256
- Iterations: 100,000 (configurable via
WorkOptions::iterations) - Salt: random 9 bytes if not provided (matching Gun.js)
- Output: base64-encoded derived key
§SHA-256 Mode
- Triggered when
WorkOptions::namestarts with"sha"(case-insensitive) - Direct SHA-256 hash of input data
- Output: base64-encoded hash
§Arguments
data— Input bytes to hashsalt— Optional salt (PBKDF2 mode only). IfNone, usesWorkOptions::saltor generates a random 9-byte salt.opts— Configuration (seeWorkOptions)
§Errors
Returns SeaError::Crypto on task join failure or internal error.