Skip to content

crypto.pbkdf2 #

Description

crypto.pbkdf2 derives a key from a password, salt, iteration count, and HMAC hash.

key requires a positive key_length in bytes. Zero or negative key lengths return an error.

fn key #

fn key(password []u8, salt []u8, count int, key_length int, h hash.Hash) ![]u8

key derives a key from the password, salt and iteration count h selects the hash used by HMAC: a digest from crypto.sha1, crypto.sha256 (SHA-224, SHA-256) or crypto.sha512 (SHA-384, SHA-512, SHA-512/224, SHA-512/256). key_length must be positive; zero and negative lengths return an error. example pbkdf2.key('test'.bytes(), '123456'.bytes(), 1000, 64, sha512.new())