我正在使用crypto++对字符串进行加密和解密。代码如下所示。该代码加密了用户名和密码。但我不知道如何再次将其解密为字符串。将加密的 SHA256 代码解密为字符串的代码是什么。谁能帮我。
#include <cryptopp/hex.h>
#include <cryptopp/sha.h>
#include <cryptopp/base64.h>
#include <iostream>
#include <string>
int main()
{
CryptoPP::SHA256 hash;
byte digest[CryptoPP::SHA256::DIGESTSIZE];
std::string username, password, salt, output;
std::cout << "Enter username: ";
std::getline(std::cin,username);
std::cout << std::endl << "Enter password: ";
std::getline(std::cin,password);
salt = username + password;
hash.CalculateDigest(digest,(const byte *)salt.c_str(),salt.size());
CryptoPP::HexEncoder encoder;
CryptoPP::StringSink *SS = new CryptoPP::StringSink(output);
encoder.Attach(SS);
encoder.Put(digest,sizeof(digest));
encoder.MessageEnd();
std::cout << "The username/password salted hash is => " << output << std::endl;
return 0;
}