Quick and strong file-encryption with OpenSSL

简介: Tuesday 16 June 2009 @ 17:31 CESTContributed by: lars To quickly encrypt a file with a password of your choice you can use OpenSSL.
Security

To quickly encrypt a file with a password of your choice you can use OpenSSL. OpenSSL supports a whole range of ciphers, including government approved encryption algorithms. The encryption algorithm AES is the only accepted open confidentiality algorithm here in Norway (read more here). AES is the new algorithm replacing DES. You can read all about AES and DES elsewhere.

To encrypt a file using AES with a 256 bit key-length:

 

$ openssl enc -e -aes-256-cbc -salt -in filename.odp -out filename.odp.enc
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

 

The encrypted file is now found as filename.odp.enc

Since symmetric block ciphers process one block of data at the time (AES uses a block length of 128 bits), it is important that we use CBC mode. CBC prevents repeating plaintext to create the same (repeating) ciphertext. Use option -p to have OpenSSL print out the salt, key and IV used:

 

$ openssl enc -e -aes-256-cbc -salt -p -in filename.odp -out filename.odp.enc
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
salt=92BCA2EA0EABCA62
key=1BCE6E251E86A6379066B634FD20CD3090981B50CDF3FF5634C49DCF4A1812A5
iv =9604DF84236BB3965083830396277636

 

To decrypt the file: Note! If you type in the wrong password, you'll get garbled output since there is no way to check if the password is correct.

 

$ openssl enc -d -aes-256-cbc -in filename.odp.enc -out filename.odp
enter aes-256-cbc decryption password:

 

And the decrypted file is found as filename.odp

For example: You can encrypt a file with a password of your choice. Send the file to the receiver, and then communicate to him over another secure communication channel what the password is (and that you've used "aes-256-cbc").

目录
相关文章
|
4月前
|
关系型数据库 MySQL
Authentication plugin ‘caching_sha2_password‘ cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2
Authentication plugin ‘caching_sha2_password‘ cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2
|
网络安全 Python
pip is configured with locations that require TLS/SSL
pip is configured with locations that require TLS/SSL
94 0
|
算法
Xftp报no matching outgoing encryption algorithm found
Xftp报no matching outgoing encryption algorithm found
111 1
Xftp报no matching outgoing encryption algorithm found
|
Python
Python常见问题 - 报错 cryptography is required for sha256_password or caching_sha2_password
Python常见问题 - 报错 cryptography is required for sha256_password or caching_sha2_password
374 0
|
网络安全
curl error: SSL certificate problem: unable to get local issuer certificate解决方案
curl error: SSL certificate problem: unable to get local issuer certificate解决方案
318 0
|
网络安全 开发工具 git
OpenSSL SSL_read: Connection was reset
使用 Git clone 一仓库,报错 fatal: unable to access 'https://github.com/lzhd/teaset-pro.git/': OpenSSL SSL_read: Connection was reset, errno 10054。这种情况一般是网络不稳定导致,如果重新 clone 尝试是否成功;如果还出现这个问题,也有可能 ssl 证书验证方面的问题, 设置 httpsslVerify属性取消ssl验证,执行如下命令。
OpenSSL SSL_read: Connection was reset
|
编译器 网络安全 Windows
解决Qt5.12版本OpenSSL不能用问题: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization faile
解决Qt5.12版本OpenSSL不能用问题: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization faile
861 0
解决Qt5.12版本OpenSSL不能用问题: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization faile
|
网络安全
RSA host key for xxx has changed and you have requested strict checking.
今天遇到了一个错误内容: RSA host key for x.x.x.x has changed and you have requested strict checking. Host key verification failed.
226 0
|
Java API
Access restriction: The type 'BASE64Decoder' is not API (restriction on required library xxx)
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/79913071 ...
2809 0