Difference between revisions of "Encrypt and decrypt files"
Jump to navigation
Jump to search
↑ https://unix.stackexchange.com/questions/162960/how-can-i-encrypt-a-file
↑ https://stackoverflow.com/a/31552829
(Created page with "== OpenSSL == * Encrypt file (<code>openssl enc</code>): :<code>openssl enc -aes-256-cbc -in un_encrypted.data -out encrypted.data</code> :Use <code>...") Tags: Mobile web edit, Mobile edit |
Tags: Mobile web edit, Mobile edit |
||
Line 1: | Line 1: | ||
== [[OpenSSL]] == | == [[OpenSSL]] == | ||
+ | |||
+ | '''Encrypt and decrypt a file'''<ref>https://unix.stackexchange.com/questions/162960/how-can-i-encrypt-a-file</ref> ([[GPG]] can also be used for encrypting and decrypting files)<br> | ||
+ | Using aes-256-cbc cypher, You will be prompted for a password when encrypting that has to be used for decrypting.<ref>https://stackoverflow.com/a/31552829</ref> | ||
* [[Encrypt]] file (<code>openssl enc</code>): | * [[Encrypt]] file (<code>openssl enc</code>): | ||
− | :<code> | + | :<code>openssl enc -[[aes-256]]-cbc -in un_encrypted.data -out encrypted.data</code> |
+ | : You can use <code>[[file (command)|file]]</code> command to verify file type. | ||
− | |||
[[file]] encrypted.data | [[file]] encrypted.data | ||
encrypted.data: openssl enc'd data with salted password | encrypted.data: openssl enc'd data with salted password | ||
+ | : Encrypt file providing password on the command line, be aware that your password will be store on [[history]] of your shell): | ||
+ | ::<code>openssl aes-256-cbc -a -salt -in twitterpost.txt -out foo.enc -pass file:<( echo -n "someGoodPassword" )</code> | ||
* [[Decrypt]] file (<code>openssl enc -d</code>): | * [[Decrypt]] file (<code>openssl enc -d</code>): | ||
− | :<code>openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data</code> | + | :<code>openssl enc '''-d''' -aes-256-cbc -in encrypted.data -out un_encrypted.data</code> |
− | |||
− | |||
== See also == | == See also == | ||
* {{openSSL}} | * {{openSSL}} |
Revision as of 11:58, 16 July 2020
OpenSSL
Encrypt and decrypt a file[1] (GPG can also be used for encrypting and decrypting files)
Using aes-256-cbc cypher, You will be prompted for a password when encrypting that has to be used for decrypting.[2]
- Encrypt file (
openssl enc
):
openssl enc -aes-256-cbc -in un_encrypted.data -out encrypted.data
- You can use
file
command to verify file type.
file encrypted.data encrypted.data: openssl enc'd data with salted password
- Encrypt file providing password on the command line, be aware that your password will be store on history of your shell):
openssl aes-256-cbc -a -salt -in twitterpost.txt -out foo.enc -pass file:<( echo -n "someGoodPassword" )
- Decrypt file (
openssl enc -d
):
openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data
See also
- OpenSSL: RSA, ECDSA, WolfSSL, AES, Diffie-Hellman (DH) key-exchange,
/etc/ssl/openssl.cnf
, OpenSSL v3
Advertising: