CryptoStreamPP
CryptoStreamPP copied to clipboard
CryptoStreamPP() alwaysInitKey parameter usage
Hello,
I was trying to decode an already encoded stream.
I was not able to decode the stream correctly until after I instantiated the stream with alwaysInitKey(true)
. Is this the right (intended) use of this parameter?
Using your example something like this...
#include "cryptostreampp/Algorithms.hpp"
#include "cryptostreampp/CryptoStreamPP.hpp"
#include "cryptostreampp/RandomNumberGenerator.hpp"
#include <iosfwd>
#include <iostream>
int main() {
using namespace cryptostreampp;
EncryptionProperties props;
props.iv = 6006631236506852901;
props.iv2 = 1573596508630574202;
props.iv3 = 4389739208682704398;
props.iv4 = 2119482576824948873;
props.cipher = Algorithm::AES;
props.password = std::string("password");
// Create a stream in output mode to create a brand new file called test.txt
CryptoStreamPP stream("test.txt", props, std::ios::out | std::ios::binary | std::ios::trunc);
stream.write("Hello, world!", 13);
stream.flush();
stream.close();
// *** Constructing with default value (false) of alwaysInitKey not working! ***
// CryptoStreamPP stream1("test.txt", props, std::ios::out | std::ios::binary);
CryptoStreamPP stream1("test.txt", props, true, std::ios::out | std::ios::binary);
// Read in a buffer of data
{
char buffer[14];
stream1.read(buffer, 13);
buffer[13] = '\0';
std::cout << buffer << std::endl;
}
stream1.close();
return 0;
}