Hi Jeff,

The new library is much faster, but I am still not getting that speed in 
the code. 1 second to encrypt 5 mb versus 3 seconds before.


*I added the .reserve(...) code also.*



 Start at: 05/12/2023 14:46:39.358
 Start Encrypted at: 05/12/2023 14:46:39.607
 in encrypt aes 
 returning cipher 
 Encrypted at: 05/12/2023 14:46:40.626


string bkey1 = "cX/8AascXHJz6Anr02GHZg==";
string biv2 = "WdHMzK+OrQOTjxZ8cAXQ6g==";
std::pair<SecByteBlock,SecByteBlock> akeys = load_aes_key_from_b64_str(bkey1, 
biv2);
cout << " Start at: " << get_curr_datetime_str() << endl;

const int num_bytes = 5000003;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dist(0,255);
std::string random_string;
random_string.reserve(num_bytes);
for(int i=0; i<num_bytes; i++){
random_string += static_cast<char>(dist(gen));
}

cout << " Start Encrypted at: " << get_curr_datetime_str() << endl;
string message_bytes = encrypt_aes(random_string, akeys.first, akeys.second
);
cout << " Encrypted at: " << get_curr_datetime_str() << endl;



std::string encrypt_aes(std::string message, SecByteBlock key, SecByteBlock 
iv) {
try {
cout <<" in encrypt aes " <<endl;
AlgorithmParameters params = MakeParameters(Name::FeedbackSize(), 1
/*8-bits*/)
(Name::IV(), ConstByteArrayParameter(iv));
CFB_Mode<AES>::Encryption e;
std::string cipher;
cipher.reserve(message.size()+16); 
e.SetKey(key, key.size(), params);
StringSource ss(message, true, new StreamTransformationFilter(e, new 
StringSink(cipher)));
cout << " returning cipher " << endl;
return cipher;
}
catch (CryptoPP::Exception e) {
std::cerr << e.what() << std::endl;
return "";
}
}





On Friday, May 12, 2023 at 10:40:10 AM UTC-4 Jeffrey Walton wrote:

> On Fri, May 12, 2023 at 10:27 AM Dwight Kulkarni <dwi...@realtime-7.com> 
> wrote:
> >
> > These are the results from CryptoPP 8.7 vs 8.1 earlier:
> > [...]
> > <TR><TD>AES/CFB (128-bit key)<TD>ARMv8<TD>344<TD>4.99<TD>1.135<TD>2044
> > [...]
>
> 5 MB / 344 MB/s = 0.01453 s = 14/53 ms. That is below 200 ms.
>
> Jeff
>

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/61cf4a2f-56b3-4328-903f-96015e6441e6n%40googlegroups.com.

Reply via email to