Storing the IV with the ciphertext Crypto++ CBC AES encryption

前端 未结 2 1000
礼貌的吻别
礼貌的吻别 2021-01-07 12:43

I\'m trying to encrypt(and decrypt after) a file using AES in CBC mode and Crypto++ library

Here\'s what I already did:

using namespace CryptoPP;
Aut         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 13:02

    The StringSink has the following documentation:

    A StringSink serves as a destination for string data in the pipelining paradigm. The data can be binary or ASCII.

    So although it is a string, it is internally an octet- or byte string. So yes, you can just save the IV and ciphertext that way.

    But to be sure, just compare the length of the result with the IV size (16 bytes) and ciphertext size together. If it is equal then you should be fine.

提交回复
热议问题