Two others:

string get_curr_datetime_str(){
return datetime_to_str(chrono::system_clock::now());

}

string datetime_to_str(std::chrono::high_resolution_clock::time_point 
utctime){ 
std::chrono::high_resolution_clock::time_point::duration tt = utctime.
time_since_epoch();
const time_t durs = std::chrono::duration_cast<std::chrono::seconds>(tt).
count();
std::ostringstream ss;
string format = "%m/%d/%Y %H:%M:%S";
if (const std::tm *tm = std::gmtime(&durs)){
ss << std::put_time(tm,format.c_str());
const long long durms = std::chrono::duration_cast<std::chrono::milliseconds
>(tt).count();
ss << "." << std::setw(3) << std::setfill('0') << int(durms - durs * 1000);
return ss.str();
}else{
return "";
}
}

On Friday, May 12, 2023 at 10:50:38 AM UTC-4 Dwight Kulkarni wrote:

> I didn't give the load_aes_key function....here it is :
>
>
>
> std::pair<SecByteBlock,SecByteBlock> load_aes_key_from_b64_str(string bkey, 
> string biv){
>
> SecByteBlock key;
> SecByteBlock iv;
> try {
> AutoSeededRandomPool prng;
> key = SecByteBlock(udp_aes_key_size_in_bytes);
> iv = SecByteBlock(udp_aes_key_iv_in_bytes);
>
> //prng.GenerateBlock(key.data(), key.size());
> //prng.GenerateBlock(iv.data(), iv.size());
> bkey = b64decode(bkey);
> biv = b64decode(biv);
>
> ArraySink sk(key.data(), key.size());
> sk.ChannelPut(DEFAULT_CHANNEL, reinterpret_cast<const byte*>(bkey.c_str
> ()),key.size());
>
> ArraySink siv(iv.data(), iv.size());
> siv.ChannelPut(DEFAULT_CHANNEL, reinterpret_cast<const byte*>(biv.c_str
> ()),iv.size());
>
> //CryptoPP::GenerateIntoBufferedTransformation(s, DEFAULT_CHANNEL, size);
> // key.data() = reinterpret_cast<byte*>(const_cast<char*>(nkey.c_str()));
> //iv.data() = reinterpret_cast<byte*>(const_cast<char*>(niv.c_str()));
> std::cout << "Loaded blocks with key size " << int(key.size()) << " and 
> iv " << int(iv.size()) << endl;
>
> return std::make_pair(key,iv);
>
> }
>
> catch (CryptoPP::Exception e) {
> std::cerr << e.what() << std::endl;
> return std::make_pair(key,iv);
> }
>
> }
>
> On Friday, May 12, 2023 at 10:48:42 AM UTC-4 Dwight Kulkarni wrote:
>
>> 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/22b58042-13b1-4b3d-a941-d33acdfa1031n%40googlegroups.com.

Reply via email to