I'm making a personal security tool in C++ and was curious how I would go about encrypting files in C++. If anyone has a method that would be great, and more specifically I was interested in 3DES encryption.
-
$\begingroup$ Welcome to crypto.stackexchange - This is a programming question, and programming questions are off-topic here even if they are about using cryptography. Programming questions belong on stackoverflow. I can migrate this to stackoverflow for you. $\endgroup$– Ella RoseJun 30, 2019 at 17:25
1 Answer
3DES is an old and slow cipher. In 2019, it is probably a bad idea to build new applications based on this algorithm.
Choosing a cipher, is not the only thing that matter in cryptography. You need a mode of operation like CBC or GCM to specify how to combine encryption function on long messages. If you don't use AEAD modes, you probably need a MAC construction to protect ciphertexts from malleability.
Choosing all theses things in a secure way is difficult.
That's why, your best option is to use a library that provide a secure API for encryption.
Libsodium is a mature example of such library and the crypto_secretbox_*
functions are probably what you need.
They are based on XSalsa20+Poly1305 construction.
-
$\begingroup$ That's awesome, thanks for the info, I'll check it out. $\endgroup$– Sean9981Jun 30, 2019 at 16:52