aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-07-16 11:47:57 -0400
committerPaul Duncan <pabs@pablotron.org>2019-07-16 11:47:57 -0400
commitb1089d91ec8a7acef32ab588917680e77862617e (patch)
treeca7d6ed5997bb8cd33571cc9b80f10a6a3849874 /main.c
downloadsha2-b1089d91ec8a7acef32ab588917680e77862617e.tar.bz2
sha2-b1089d91ec8a7acef32ab588917680e77862617e.zip
initial commit
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..5ef63fc
--- /dev/null
+++ b/main.c
@@ -0,0 +1,20 @@
+#include <stdio.h> // printf()
+#include <string.h> // strlen()
+#include "sha256.h"
+
+static const char DEFAULT[] = "The quick brown fox jumps over the lazy dog";
+
+int main(int argc, char *argv[]) {
+ const char *src = (argc > 1) ? argv[1] : DEFAULT;
+ uint8_t dst[SHA256_HASH_SIZE];
+
+ sha256((const uint8_t *) src, strlen(src), dst);
+
+ printf("src = \"%s\"\nhash = \"", src);
+ for (size_t i = 0; i < 32; i++) {
+ printf("%02x", dst[i]);
+ }
+ printf("\"\n");
+
+ return 0;
+}