An easy way to encrypt and decrypt large files using OpenSSL and Linux:
Generate PEM public private key using openssl:
We can generate hash using md5sum for both files so we can compare them once we decrypt our file:
Decrypt large file using OpenSSL:
Check md5sum output:
#linux #openssl #pem #encryption #decryption #x509 #public_key #private_key
Generate PEM public private key using openssl:
openssl req -x509 -nodes -newkey rsa:2048 -keyout private-key.pem -out public-key.pemEncrypt file using public key PEM file:
openssl smime -encrypt -binary -aes-256-cbc -in large_file.img -out large_file.img.dat -outform DER public-key.pem
We can generate hash using md5sum for both files so we can compare them once we decrypt our file:
md5sum large_file.img*
#cd573cfaace07e7949bc0c46028904ff large_file.img
#c4d8f1e868d1176d8aa5363b0bdf8e7c large_file.img.dat
Decrypt large file using OpenSSL:
openssl smime -decrypt -in large_file.img.dat -binary -inform DEM -inkey private-key.pem -out decrypted_large_file.img
Check md5sum output:
md5sum *large_file.img*
#cd573cfaace07e7949bc0c46028904ff decrypted_large_file.img
#cd573cfaace07e7949bc0c46028904ff large_file.img
#c4d8f1e868d1176d8aa5363b0bdf8e7c large_file.img.dat
#linux #openssl #pem #encryption #decryption #x509 #public_key #private_key