0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00
openvpn3/test/unittests/test_crypto_hashstr.cpp
Arne Schwabe aec6ba3b71 [test/misc] Convert hashstr to unit test
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-07-01 15:57:30 +02:00

20 lines
622 B
C++

#include "test_common.h"
#include <openvpn/common/file.hpp>
#include <openvpn/ssl/sslchoose.hpp>
#include <openvpn/crypto/cryptoalgs.hpp>
#include <openvpn/crypto/hashstr.hpp>
using namespace openvpn;
TEST(crypto, hashstr) {
const std::string content = read_text_utf8(UNITTEST_SOURCE_DIR "/input/1984.txt");
DigestFactory::Ptr digest_factory(new CryptoDigestFactory<SSLLib::CryptoAPI>());
HashString hash(*digest_factory, CryptoAlgs::MD5);
hash.update(content);
const std::string actual = hash.final_hex();
const std::string expected = "2bea7a83bf94971af26372126ebba7e3";
ASSERT_EQ (actual, expected);
}