Encryption and encoding

How to encode end encrypt files.

Encode a file

Encode a text

openssl enc -base64 -in yourFile.txt -out yourFile.base64

Decode a text

openssl enc -d -base64 -in yourFile.base64 -out yourFile.txt

Encrypt a file with AES chiper

openssl enc -aes256 -base64 -in yourFile.txt -out yourFile.enc

Decrypt a file with AES chiper

openssl aes256 -salt -a -d -in yourFile.enc -out yourFile.txt

Symmetic encryption

openssl aes-256-cbc -salt -a -e -in yourFile.txt -out yourFile.enc

Symmetic decryption

openssl aes-256-cbc -salt -a -d -in yourFile.enc -out yourFile.txt

Asymmetric encryption

For this we need to generate a private key from which will extract the public key. So the file will be encrypted with the public key and decripted with the private key.

Generate private key with password

openssl genrsa -aes256 -out private.key 2068

Extract the public key

openssl rsa -in private.key -pubout -out public.key

Encrypt with public key

openssl rsautl -encrypt -pubin -inkey public.key -in plaintext.txt -out encrypted.txt