1. base64 encoding/Decoding
Many people think of uencode when talking about how to send email attachments under the command line. You can also use base64 encoding. Use openssl base64 encoding/decoding:
$ Openssl base64 <filename. bin> filename.txt
$ Openssl base64-d <filename.txt> filename. bin
2. Check file consistency
There are many methods for verifying file consistency in UNIX, such as sum, cksum, md5sum, and sha1sum. Sum and cksum are suitable for simple verification, and the generated verification code is easy to duplicate. Md5sum has a security vulnerability. Currently, sha1sum is recommended. However, sha1sum is used differently on different platforms. Considering the cross-platform nature, openssl is recommended.
$ Openssl sha1 filename
SHA1 (filename) = e83a42b9bc8431a6645099be50b6341a35d3dceb
$ Openssl md5 filename
MD5 (filename) = 26e9855f8ad6a5906fea121283c729c4
3. file encryption/Decryption
OpenSSL supports many encryption algorithms, but some algorithms are not recommended for backward compatibility, such as DES and RC4-40. The recommended encryption algorithms are bf (Blowfish) and-aes-128-cbc (128-bit key AES encryption algorithm running in CBC mode), and the encryption strength is guaranteed.
Encryption example:
$ Openssl enc-aes-128-cbc <filename> filename. aes-128-cbc
Enter aes-128-cbc encryption password:
Verifying-enter aes-128-cbc encryption password:
Decryption example:
$ Openssl enc-d-aes-128-cbc-in filename. aes-128-cbc> filename
Enter aes-128-cbc decryption password: