Last active
September 30, 2020 04:30
-
-
Save castironclay/5f58b75c8bac0f8efee1c8328604cd0a to your computer and use it in GitHub Desktop.
OpenSSL Encrypt / Decrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Done on raspberry pi 4 | |
## Linux pi4-master 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l GNU/Linux | |
## OpenSSL 1.1.1d 10 Sep 2019 | |
# Generate Keys | |
ssh-keygen -t rsa -b 4096 -C "[email protected]" | |
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa | |
ssh-keygen -f id_rsa.pub -e -m PKCS8 > id_rsa.pem.pub | |
# Create password string | |
openssl rand -out aes256_pass.txt -base64 50 | |
#Encrypt file | |
openssl enc -e -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -pass file:./aes256_pass.txt -in secret.txt -out cipher.txt | |
#Encrypt password file | |
openssl rsautl -encrypt -pubin -inkey id_rsa.pem.pub -in aes256_pass.txt -out aes256_pass_cipher.txt | |
#Decret password file | |
openssl rsautl -decrypt -inkey id_rsa -in aes256_pass_cipher.txt > ~/aes256_pass.txt | |
#Decrypt file | |
openssl enc -d -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -pass file:~/aes256_pass.txt -in cipher.txt -out ~/secret.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment