최근에 AES256을 사용하여 데이터를 암호화/해독하는 서버를 만들었습니다. 제대로 보내려면 시간이 걸렸습니다. 그러나 이제는 메모리가 부족하다고 생각하는 문제가 있습니다. "hello"라는 단어를 보내면 벌금을 해독합니다. "helloo"를 보내면 벌금이 해지됩니다. "helloo"보다 암호 해독 중에 오류가 발생하고 암호화 된 문자열을 인쇄하면받은 문자열에 이전 문자열의 길이를 더한 값이 더해집니다.암호 해독 메모리 문제
예컨대
hello: ####################
helloo: ##############################
hi: #####(#########################) //has the additional length made up from the encrypted string of "helloo" minus the first however many characters "hi" is
코드 :
std::string decryptString(std::string ciphertext, byte *key, byte *iv)
{
std::string decodedtext;
CryptoPP::StringSource(ciphertext, true,
new CryptoPP::HexDecoder(new CryptoPP::StringSink(decodedtext)));
std::string plaintext;
CryptoPP::GCM<CryptoPP::AES>::Decryption dec;
dec.SetKeyWithIV((const byte *)key, CryptoPP::AES::MAX_KEYLENGTH,
(const byte *)iv, CryptoPP::AES::BLOCKSIZE);
CryptoPP::AuthenticatedDecryptionFilter adf(dec, new CryptoPP::StringSink(plaintext));
adf.Put((const byte *)decodedtext.data(), decodedtext.size());
adf.MessageEnd();
return plaintext;
}
시도하지만, 코드없이 ... 하드 이제 – DarkSquirrel42
을 말해 ** 암호화를 수행하는 코드를 게시 할 수 있습니다. – QuantumMechanic
decryptString (...)을 호출하는 코드를 표시 할 수 있습니까? 나는'cyphertext'가 새로운 문자열을 넣을 때 여전히 이전 문자열을 포함한다고 생각합니다 ... 새로운 문자열 – DarkSquirrel42