On Thu, May 11, 2023 at 4:24 PM Dwight Kulkarni <dwi...@realtime-7.com> wrote: > > I created a 5 MB message and encrypted it. The message takes 3 seconds to > encrypt. I needed something around 200 ms, even if the encryption is weaker. > > My code is below, should I be setting any flags when compiling the library to > make it fast ? > > Got message str at: 05/11/2023 20:21:31.346 > in encrypt aes > Encrypted at: 05/11/2023 20:21:33.027 > > message_bytes = encrypt_aes(message_bytes, key, iv); > 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; > 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 ""; > } > }
You should probably avoid multiple resizes on cipher object. Add something like: std::string cipher; cipher.reserve(message.size()+16); Otherwise, please run the benchmarks and report back: cryptest.exe b2 3 <cpufreq in GHz> Also see https://cryptopp.com/wiki/Benchmarks . 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/CAH8yC8%3DFPNNNZzS6X4Tyht_0Q759AmOVrj_XSTYf8HNbvY-nKw%40mail.gmail.com.