#include #include #include #include TEST(Crypto, Basic) { std::string key = "m{L%H$HgY##LJ&6Fs"; CryptoBusiness cryptoBusiness; cryptoBusiness.setKey(key); std::string data = "some data"; std::string encrypted = cryptoBusiness.encrypt(data); std::string decrypted = cryptoBusiness.decrypt(encrypted); ASSERT_NE(encrypted, decrypted); ASSERT_EQ(data, decrypted); } TEST(Crypto, Hex1) { CryptoBusiness cryptoBusiness; std::string data = "some data"; std::string toHex = cryptoBusiness.toHex(data); std::string fromHex = cryptoBusiness.fromHex(toHex); ASSERT_NE(toHex, fromHex); ASSERT_EQ(data, fromHex); } TEST(Crypto, Hex2) { CryptoBusiness cryptoBusiness; std::string data; for (int i = 0; i <= 255; ++i) { data += (char)i; } std::string toHex = cryptoBusiness.toHex(data); std::string fromHex = cryptoBusiness.fromHex(toHex); ASSERT_NE(toHex, fromHex); ASSERT_EQ(data, fromHex); } TEST(Crypto, EncryptHex) { std::string key = "m{L%H$HgY##LJ&6Fs"; CryptoBusiness cryptoBusiness; cryptoBusiness.setKey(key); std::string data = "some data"; std::string encrypted = cryptoBusiness.encryptToHex(data); std::string decrypted = cryptoBusiness.decryptFromHex(encrypted); ASSERT_NE(encrypted, decrypted); ASSERT_EQ(data, decrypted); } int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }