Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
106
rated 0 times [  106] [ 0]  / answers: 1 / hits: 250322  / 1 Year ago, tue, may 30, 2023, 10:40:55

I want to encrypt a file using AES-256. How can I do that quickly and easily, and how can I - or someone else -decrypt it again?


More From » encryption

 Answers
7

Unfortunately, there is no easy solution to securing your stuff. Think about your use-case, maybe something other than plain AES is better suited.








If you want very simple platform independent encryption, you can use openssl.



Please note: You can use this to hide birthday-gift-ideas.txt from your roommate, but don't expect it to be secure against a determined attacker!




  1. As was pointed out in the comments, this method uses a naive key derivation function, so your password needs to be superlatively good in order for you to have a chance of being secure.

  2. Additionally, this method doesn't authenticate the ciphertext, which means an attacker can modify or corrupt the contents without you noticing.

  3. For many types of security, encryption is simply not enough (e.g. you can't just use encryption to communicate securely)



If you still want to use openssl:




  • Encryption:



    openssl aes-256-cbc -in attack-plan.txt -out message.enc


  • Decryption:



    openssl aes-256-cbc -d -in message.enc -out plain-text.txt




You can get openssl to base64-encode the message by using the -a switch on both encryption and decryption. This way, you can paste the ciphertext in an email message, for example. It'll look like this:



stefano:~$ openssl aes-256-cbc -in attack-plan.txt -a
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
U2FsdGVkX192dXI7yHGs/4Ed+xEC3ejXFINKO6Hufnc=


Note that you have a choice of ciphers and modes of operation. For normal use, I recommend aes 256 in CBC mode. These are the ciphers modes you have available (only counting AES):



aes-128-cbc ← this is okay
aes-128-ecb
aes-192-cbc
aes-192-ecb
aes-256-cbc ← this is recommended
aes-256-ecb


See also:





Please note:



OpenSSL will ask you for a password. This is not an encryption key, it is not limited to 32 bytes! If you're going to transfer files with someone else, your shared secret should be very strong. You can use this site to get a sense of how good your password is:





Warning: I have checked that these sites don't send your password to the server, but that can change at any time. Use these sites with dev tools / inspector and check if they send anything before typing in your strong password.


[#43548] Thursday, June 1, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dicatandyca

Total Points: 486
Total Questions: 108
Total Answers: 121

Location: Greenland
Member since Wed, Jan 18, 2023
1 Year ago
dicatandyca questions
;