summaryrefslogtreecommitdiff
path: root/modules/crypto/tests
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-07-18 15:47:29 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-07-18 15:47:29 +0200
commitf1223709e193c4513047293a1a42b55b9e8874b8 (patch)
tree874e76039ec3885e1448d69f14abd42763f4ba7b /modules/crypto/tests
parente732c6efd96a22296591f3becc1c63fc80299938 (diff)
Added argon2i as hashing alg with one test
Diffstat (limited to 'modules/crypto/tests')
-rw-r--r--modules/crypto/tests/argon2i.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/crypto/tests/argon2i.cpp b/modules/crypto/tests/argon2i.cpp
new file mode 100644
index 0000000..9f8efc5
--- /dev/null
+++ b/modules/crypto/tests/argon2i.cpp
@@ -0,0 +1,33 @@
+#include <forstio/test/suite.hpp>
+#include <forstio/codec/data.hpp>
+#include <forstio/codec/base64.hpp>
+
+#include "../c++/hash.hpp"
+
+#include <iostream>
+namespace {
+namespace sch {
+using namespace saw::schema;
+}
+SAW_TEST("Codec Base64 Encode String"){
+ using namespace saw;
+
+ data<sch::String> inp_data{"Hello, World!"};
+ data<sch::String> salt{"salty678"};
+
+ hash<crypto::Argon2i> hasher;
+
+ auto eov = hasher.apply(inp_data, salt);
+ SAW_EXPECT(eov.is_value(), (std::string{"Hashing failed. "} + std::string{eov.get_error().get_message()}) );
+ auto& val = eov.get_value();
+
+ data<sch::String, encode::Base64> base64_str;
+ codec<sch::String, encode::Base64> base64_codec;
+ auto eob64 = base64_codec.encode(val, base64_str);
+ SAW_EXPECT(eob64.is_value(), "Couldn't encode data");
+
+ data<sch::String, encode::Base64> check_against{"J082QuWpLuV3UnaVScg4NbUYLfb5VNKp4HAiPOevEbB+EZsxUbwSOoYUNUsXgEcvF2/lbysX0NBGDN5gcc1/TF0YIUi0xGAcNeK6DP5bZckqMrN7WRlCxugmSQLQ18SzDmIKdwxSo2vWO0ivV2m7ZGOxCdrfxZ26ivRUkeazOFA="};
+ SAW_EXPECT(base64_str == check_against, "Base64 not expected value");
+
+}
+}