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
Tags: Mobile web edit, Mobile edit |
Tags: Mobile web edit, Mobile edit |
||
Line 28: | Line 28: | ||
* <code>[[ansible-vault encrypt]]</code> | * <code>[[ansible-vault encrypt]]</code> | ||
* [[aws-encryption-cli]] | * [[aws-encryption-cli]] | ||
+ | * [[aws kms encrypt]] | ||
== See also == | == See also == |
Revision as of 22:47, 13 May 2022
Using 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
macOS options:
-salt
Use a salt in the key derivation routines (the default). When the salt is being used the first eight bytes of the encrypted data are reserved for the salt: it is randomly generated when encrypting a file and read from the encrypted file when it is decrypted.
Related terms
zip -r -0 -e encrypted_file.zip /path/to/files
- PGP
ansible-vault encrypt
- aws-encryption-cli
- aws kms encrypt
See also
- OpenSSL: RSA, ECDSA, WolfSSL, AES, Diffie-Hellman (DH) key-exchange,
/etc/ssl/openssl.cnf
, OpenSSL v3 - Encryption, openssl, ecryptfs, encfs, GPG, PGP, Symantec Encryption Desktop, VeraCrypt, CMEK, BitLocker, OAEP, Cypher
Advertising: