| Title: | Secure Password Hashing |
|---|---|
| Description: | Utilities for secure password hashing via the argon2 algorithm. It is a relatively new hashing algorithm and is believed to be very secure. The 'argon2' implementation included in the package is the reference implementation. The package also includes some utilities that should be useful for digest authentication, including a wrapper of 'blake2b'. For similar R packages, see sodium and 'bcrypt'. See <https://en.wikipedia.org/wiki/Argon2> or <https://eprint.iacr.org/2015/430.pdf> for more information. Compatibility updates by Renova. |
| Authors: | Drew Schmidt [aut, cre] |
| Maintainer: | Drew Schmidt <[email protected]> |
| License: | BSD 2-clause License + file LICENSE |
| Version: | 0.4.0.9001 |
| Built: | 2026-11-13 17:46:50 UTC |
| Source: | https://github.com/renova-r/argon2 |
Utilities for secure password hashing via the argon2 algorithm. It is a relatively new hashing algorithm and is believed to be very secure. The argon2 implementation included in the package is the reference implementation. The package also includes some utilities that should be useful for digest authentication, including a wrapper of blake2b. For similar R packages, see sodium and bcrypt.
Drew Schmidt
Project URL: https://github.com/wrathematics/argon2
A 512-bit blake2b hash implementation.
blake2b(x, key = NULL)blake2b(x, key = NULL)
x |
Input to be hashed. Can be a single string or a raw vector. |
key |
An optional key. Should be |
The hash of the string as a raw vector.
Aumasson, J.P., Neves, S., Wilcox-O'Hearn, Z. and Winnerlein, C., 2013, June. BLAKE2: simpler, smaller, fast as MD5. In International Conference on Applied Cryptography and Network Security (pp. 119-135). Springer Berlin Heidelberg.
## Not run: library(argon2) blake2b("some string") blake2b("another") ## End(Not run)## Not run: library(argon2) blake2b("some string") blake2b("another") ## End(Not run)
Generates a random raw (unsigned char*) vector.
gen_nonce(length = 64)gen_nonce(length = 64)
length |
The number of elements to return. |
A random raw vector.
Basic password hashing. Use pw_hash() to hash and pw_check()
to compare a possible password with the hashed password.
pw_hash(pass, variant = "i", iterations = 16, memory = 8, nthreads = 2) pw_check(hash, pass)pw_hash(pass, variant = "i", iterations = 16, memory = 8, nthreads = 2) pw_check(hash, pass)
pass |
The (plaintext) password. |
variant |
Choice of algorithm; currently the only supported choices are "i" and "d". |
iterations |
A time cost. Recommended to be at least 10. Can be any integer from 1 to 2^31 - 1. |
memory |
A memory cost, given in MiB. Recommended to be at least 8. Can be any integer from 1 to 2^21 - 1 (but don't be ridiculous). |
nthreads |
Number of threads. This affects the speed of hashing, so more is better. |
hash |
The hashed password; this is the output of |
The default options for iterations and memory should be
sufficient for most purposes. You are encouraged to read the official
documentation before modifying these values, which can be found here
https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf.
On the other hand, nthreads is safe to change to fit your available
resources, and you are encouraged to do so.
This uses the argon2 (i or d variety) hash algorithm. See references for details and implementation source code (also bundled with this package).
Our binding uses a 512 bit salt with data generated from MT.
pw_hash() returns a hash to be used as an input to pw_check().
pw_check() returns TRUE or FALSE, whether or not
the plaintext password matches its hash.
Biryukov, A., Dinu, D. and Khovratovich, D., 2015. Fast and Tradeoff-Resilient Memory-Hard Functions for Cryptocurrencies and Password Hashing. IACR Cryptology ePrint Archive, 2015, p.430.
Reference implementation https://github.com/P-H-C/phc-winner-argon2
## Not run: library(argon2) pass <- "myPassw0rd!" hash <- pw_hash(pass) hash # store this pw_check(hash, pass) pw_check(hash, "password") pw_check(hash, "1234") ## End(Not run)## Not run: library(argon2) pass <- "myPassw0rd!" hash <- pw_hash(pass) hash # store this pw_check(hash, pass) pw_check(hash, "password") pw_check(hash, "1234") ## End(Not run)
Convert the literal bytes of a raw (unsigned char*) to a
string representation. This is different from R's
rawToChar(). See examples for details.
raw_as_char(raw, upper = TRUE, spaces = FALSE)raw_as_char(raw, upper = TRUE, spaces = FALSE)
raw |
A raw vector. |
upper |
Should hex digits A-F be given in uppercase? |
spaces |
Should the str use spaces? |
A character string.
## Not run: library(argon2) str <- "some text" raw <- charToRaw(str) raw rawToChar(raw) raw_as_char(raw) ## End(Not run)## Not run: library(argon2) str <- "some text" raw <- charToRaw(str) raw rawToChar(raw) raw_as_char(raw) ## End(Not run)