From f1223709e193c4513047293a1a42b55b9e8874b8 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Thu, 18 Jul 2024 15:47:29 +0200 Subject: Added argon2i as hashing alg with one test --- modules/crypto/tests/argon2i.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 modules/crypto/tests/argon2i.cpp (limited to 'modules/crypto/tests') 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 +#include +#include + +#include "../c++/hash.hpp" + +#include +namespace { +namespace sch { +using namespace saw::schema; +} +SAW_TEST("Codec Base64 Encode String"){ + using namespace saw; + + data inp_data{"Hello, World!"}; + data salt{"salty678"}; + + hash 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 base64_str; + codec base64_codec; + auto eob64 = base64_codec.encode(val, base64_str); + SAW_EXPECT(eob64.is_value(), "Couldn't encode data"); + + data check_against{"J082QuWpLuV3UnaVScg4NbUYLfb5VNKp4HAiPOevEbB+EZsxUbwSOoYUNUsXgEcvF2/lbysX0NBGDN5gcc1/TF0YIUi0xGAcNeK6DP5bZckqMrN7WRlCxugmSQLQ18SzDmIKdwxSo2vWO0ivV2m7ZGOxCdrfxZ26ivRUkeazOFA="}; + SAW_EXPECT(base64_str == check_against, "Base64 not expected value"); + +} +} -- cgit v1.2.3