### Argon2 Benchmark Output Example Source: https://github.com/p-h-c/phc-winner-argon2/blob/master/README.md Example output from the Argon2 benchmark executable, showing performance metrics like cycles per byte (cpb) and total cycles for different Argon2 variants, memory sizes, and thread counts. ```text $ ./bench Argon2d 1 iterations 1 MiB 1 threads: 5.91 cpb 5.91 Mcycles Argon2i 1 iterations 1 MiB 1 threads: 4.64 cpb 4.64 Mcycles 0.0041 seconds Argon2d 1 iterations 1 MiB 2 threads: 2.76 cpb 2.76 Mcycles Argon2i 1 iterations 1 MiB 2 threads: 2.87 cpb 2.87 Mcycles 0.0038 seconds Argon2d 1 iterations 1 MiB 4 threads: 3.25 cpb 3.25 Mcycles Argon2i 1 iterations 1 MiB 4 threads: 3.57 cpb 3.57 Mcycles 0.0048 seconds (...) Argon2d 1 iterations 4096 MiB 2 threads: 2.15 cpb 8788.08 Mcycles Argon2i 1 iterations 4096 MiB 2 threads: 2.15 cpb 8821.59 Mcycles 13.0112 seconds Argon2d 1 iterations 4096 MiB 4 threads: 1.79 cpb 7343.72 Mcycles Argon2i 1 iterations 4096 MiB 4 threads: 2.72 cpb 11124.86 Mcycles 19.3974 seconds (...) ``` -------------------------------- ### Hash Password with Argon2i (High-level and Low-level APIs) Source: https://github.com/p-h-c/phc-winner-argon2/blob/master/README.md This example demonstrates hashing the string 'password' using both the high-level and low-level APIs of libargon2 with Argon2i. It sets time cost to 2, memory cost to 64 MiB, and parallelism to 1. Note: the salt is hardcoded to all zeros for simplicity; use a random salt in production applications. ```c #include "argon2.h" #include #include #include #define HASHLEN 32 #define SALTLEN 16 #define PWD "password" int main(void) { uint8_t hash1[HASHLEN]; uint8_t hash2[HASHLEN]; uint8_t salt[SALTLEN]; memset( salt, 0x00, SALTLEN ); uint8_t *pwd = (uint8_t *)strdup(PWD); uint32_t pwdlen = strlen((char *)pwd); uint32_t t_cost = 2; // 2-pass computation uint32_t m_cost = (1<<16); // 64 mebibytes memory usage uint32_t parallelism = 1; // number of threads and lanes // high-level API argon2i_hash_raw(t_cost, m_cost, parallelism, pwd, pwdlen, salt, SALTLEN, hash1, HASHLEN); // low-level API argon2_context context = { hash2, /* output array, at least HASHLEN in size */ HASHLEN, /* digest length */ pwd, /* password array */ pwdlen, /* password length */ salt, /* salt array */ SALTLEN, /* salt length */ NULL, 0, /* optional secret data */ NULL, 0, /* optional associated data */ t_cost, m_cost, parallelism, parallelism, ARGON2_VERSION_13, /* algorithm version */ NULL, NULL, /* custom memory allocation / deallocation functions */ /* by default only internal memory is cleared (pwd is not wiped) */ ARGON2_DEFAULT_FLAGS }; int rc = argon2i_ctx( &context ); if(ARGON2_OK != rc) { printf("Error: %s\n", argon2_error_message(rc)); exit(1); } free(pwd); for( int i=0; i