summaryrefslogtreecommitdiff
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
downloaduse-argon2-63104f0716dc2d60842f19fc145ea4bcb096292d.tar.gz
use-argon2-63104f0716dc2d60842f19fc145ea4bcb096292d.tar.bz2
use-argon2-63104f0716dc2d60842f19fc145ea4bcb096292d.zip
initial commitHEADmaster
-rw-r--r--.gitignore2
-rw-r--r--argon-test.c39
-rw-r--r--compile_flags.txt6
-rw-r--r--makefile14
4 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d8cf8ef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
1argon-test
2argon-test.o
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}
diff --git a/compile_flags.txt b/compile_flags.txt
new file mode 100644
index 0000000..ac8ad67
--- /dev/null
+++ b/compile_flags.txt
@@ -0,0 +1,6 @@
1-Wall
2-Werror
3-std=c99
4-pedantic
5-g
6-I/usr/local/include
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..ff2440a
--- /dev/null
+++ b/makefile
@@ -0,0 +1,14 @@
1.PHONY: clean all
2
3all: argon-test
4
5CFLAGS =-Wall -Werror -std=c99 -pedantic -g
6
7argon-test: argon-test.o
8 cc $(LDFLAGS) argon-test.o -largon2 -o $@
9
10argon-test.o: argon-test.c
11 cc $(CFLAGS) -c $< -o $@
12
13clean:
14 rm -f argon-test.o argon-test