Function strHash [src]
Compute a hash of a password using the argon2 key derivation function.
The function returns a string that includes all the parameters required for verification.
Prototype
pub fn strHash( password: []const u8, options: HashOptions, out: []u8, ) Error![]const u8
Parameters
password: []const u8
options: HashOptions
out: []u8
Possible Errors
mlockall
is enabled, and the memory needed to spawn the thread
would exceed the limit.
Not enough userland memory to spawn the thread.
The kernel cannot allocate sufficient memory to allocate a task structure for the child, or to copy those parts of the caller's context that need to be copied.
A system-imposed limit on the number of threads was encountered. There are a number of limits that may trigger this error:
- the RLIMIT_NPROC soft resource limit (set via setrlimit(2)), which limits the number of processes and threads for a real user ID, was reached;
- the kernel's system-wide limit on the number of processes and threads, /proc/sys/kernel/threads-max, was reached (see proc(5));
- the maximum number of PIDs, /proc/sys/kernel/pid_max, was reached (see proc(5)); or
- the PID limit (pids.max) imposed by the cgroup "process num‐ ber" (PIDs) controller was reached.
Source
pub fn strHash(
password: []const u8,
options: HashOptions,
out: []u8,
) Error![]const u8 {
const allocator = options.allocator orelse return Error.AllocatorRequired;
switch (options.encoding) {
.phc => return PhcFormatHasher.create(
allocator,
password,
options.params,
options.mode,
out,
),
.crypt => return Error.InvalidEncoding,
}
}