summaryrefslogtreecommitdiff
path: root/argon-test.c
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2026-07-06 23:20:17 +0200
committerThomas Schmucker <ts@its1.de>2026-07-06 23:20:17 +0200
commit63104f0716dc2d60842f19fc145ea4bcb096292d (patch)
tree17c18988744b842062c1d57db4101513aea6e9a6 /argon-test.c
downloaduse-argon2-master.tar.gz
use-argon2-master.tar.bz2
use-argon2-master.zip
initial commitHEADmaster
Diffstat (limited to 'argon-test.c')
-rw-r--r--argon-test.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/argon-test.c b/argon-test.c
new file mode 100644
index 0000000..cd2dcff
--- /dev/null
+++ b/argon-test.c
@@ -0,0 +1,39 @@
1// Standard C
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <stdint.h>
6
7// PW-Hashing
8#include <argon2.h>
9
10int
11main(void)
12{
13 const char pwd[] = "Hallo Welt";
14 char salt[24];
15 uint32_t t_cost = 20;
16 uint32_t m_cost = 1600;
17 uint32_t parallelism = 4;
18 uint32_t hashlength = 24;
19 char encoded[256] = { 0 };
20
21 arc4random_buf(salt, sizeof salt);
22 int res = argon2id_hash_encoded(t_cost, m_cost, parallelism, pwd, strlen(pwd), salt, sizeof salt, hashlength, encoded, sizeof encoded);
23 if ( res == ARGON2_OK ) {
24 printf("hash: %s\n", encoded);
25
26 res = argon2id_verify(encoded, "Hallo Welt", 10);
27 if ( res == ARGON2_OK ) {
28 puts("Alles OK!");
29 }
30 else {
31 fprintf(stderr, "Error: %s\n", argon2_error_message(res));
32 }
33 }
34 else {
35 fprintf(stderr, "Error: %s\n", argon2_error_message(res));
36 }
37
38 return EXIT_SUCCESS;
39}