Cipher encrypt example
#include "string/encoding.h"
#include <iostream>
int main(int argc, char** argv)
{
std::cout << "Password: " << password << std::endl;
std::string salt = (argc > 2) ? argv[2] : "12345678";
std::cout << "Salt: " << salt << std::endl;
std::cout <<
"Cipher name: " << cipher.
name() << std::endl;
std::cout <<
"Cipher iterations: " << cipher.
iterations() << std::endl;
std::cout << "Please enter strings to encrypt. Enter '0' to exit..." << std::endl;
std::string line;
while (getline(std::cin, line))
{
if (line.empty() || (line == "0"))
break;
std::string encrypted = cipher.
Encrypt(line);
std::string encoded = CppCommon::Encoding::Base64Encode(encrypted);
std::cout << encoded << std::endl;
}
return 0;
}
void Initialize(std::string_view secret)
Initialize the cipher with the given secret key.
const std::string & name() const noexcept
Get the cipher algorithm name.
size_t iterations() const noexcept
Get the count of key hashing iterations.
std::string Encrypt(std::string_view str)
Encrypt the given string.