diff options
Diffstat (limited to 'modules/crypto/tests/argon2i.cpp')
-rw-r--r-- | modules/crypto/tests/argon2i.cpp | 33 |
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"); + +} +} |