Types
NimwordHashingAlgorithm = enum nhaPbkdf2Sha256 = "pbkdf2_sha256", nhaPbkdf2Sha512 = "pbkdf2_sha512", nhaArgon2i = "argon2i", nhaArgon2id = "argon2id", nhaDefault
- The number of different hashing algorithms nimword supports Source Edit
Procs
proc hashEncodePassword(password: Password; iterations: int; algorithm: NimwordHashingAlgorithm = nhaDefault): string {. ...raises: [OSError, ValueError, Exception, SodiumError], tags: [RootEffect], forbids: [].}
-
Hashes and encodes the given password using the argon2 algorithm from libsodium.
Returns the hash as part of a larger string containing hash, iterations, algorithm, salt and any further values used to calculate the hash. The pattern depends on the algorithm chosen.
The return value can be used with isValidPassword .
The salt is randomly generated during the process.
For guidance on choosing values for iterations consult the libsodium-documentation
Source Edit proc isValidPassword(password: Password; encodedHash: string): bool {....raises: { UnknownAlgorithmError, ValueError, Pbkdf2Error, SodiumError, Exception}, tags: [RootEffect], forbids: [].}
-
Verifies that a given plain-text password can be used to generate the hash contained in encodedHash with the parameters provided in encodedHash.
encodedHash must be a string with the kind of pattern that encodeHash procs or and hashEncodePassword generate.
Raises UnknownAlgorithmError if the encoded hash string is for an algorithm not supported by nimword.
Source Edit