저는 잠시 동안 검색을 해왔고 CryptoPP :: TEA 암호화에 관한 문서를 찾을 수 없었습니다.Cryptopp :: TEA를 사용하여 데이터를 암호화하는 방법?
누구나 CryptoPP :: TEA를 사용하여 데이터를 암호화하는 방법을 알고 계십니까?
감사합니다.
저는 잠시 동안 검색을 해왔고 CryptoPP :: TEA 암호화에 관한 문서를 찾을 수 없었습니다.Cryptopp :: TEA를 사용하여 데이터를 암호화하는 방법?
누구나 CryptoPP :: TEA를 사용하여 데이터를 암호화하는 방법을 알고 계십니까?
감사합니다.
누구나 CryptoPP :: TEA를 사용하여 데이터를 암호화하는 방법을 알고 있습니까?
Crypto ++는 TEA 및 XTEA에 대한 구현을 제공합니다. 더 새로운 TEA 변형이 있기 때문에 몇 가지 interop 문제가있을 수 있습니다 (하지만 세부 정보는 기억하지 않습니다).
TEA와 XTEA는 블록 암호 일 뿐이므로 다른 블록 암호 (예 : 3DES, AES 또는 Cameilla)처럼 사용할 수 있습니다. 다른 블록 암호처럼 사용할 수 있으므로 아래 코드는 Crypto ++의 CBC Mode wiki 페이지에서 가져온 것입니다. 내가 한 모든 일은 AES를 차로 바꾸는 것이 었습니다.
$ ./cryptopp-test.exe
plain text: CBC Mode Test
cipher text: 483ABA61693D885532604E376703A91D
recovered text: CBC Mode Test
그리고 여기에 프로그램입니다 :
AutoSeededRandomPool prng;
SecByteBlock key(TEA::DEFAULT_KEYLENGTH);
prng.GenerateBlock(key, key.size());
byte iv[ TEA::BLOCKSIZE ];
prng.GenerateBlock(iv, sizeof(iv));
string plain = "CBC Mode Test";
string cipher, encoded, recovered;
/*********************************\
\*********************************/
try
{
cout << "plain text: " << plain << endl;
CBC_Mode<TEA>::Encryption e;
e.SetKeyWithIV(key, key.size(), iv);
StringSource ss(plain, true,
new StreamTransformationFilter(e,
new StringSink(cipher)
) // StreamTransformationFilter
); // StringSource
}
catch(const CryptoPP::Exception& e)
{
cerr << e.what() << endl;
exit(1);
}
/*********************************\
\*********************************/
// Pretty print cipher text
StringSource ss(cipher, true,
new HexEncoder(
new StringSink(encoded)
) // HexEncoder
); // StringSource
cout << "cipher text: " << encoded << endl;
/*********************************\
\*********************************/
try
{
CBC_Mode<TEA>::Decryption d;
d.SetKeyWithIV(key, key.size(), iv);
StringSource ss(cipher, true,
new StreamTransformationFilter(d,
new StringSink(recovered)
) // StreamTransformationFilter
); // StringSource
cout << "recovered text: " << recovered << endl;
}
catch(const CryptoPP::Exception& e)
{
cerr << e.what() << endl;
exit(1);
}
안녕 jww가, 답장을 보내 주셔서 감사, 이들은 매우 도움이 여기에
프로그램의 출력입니다. – aj3423