Use of OpenSSL command lines in Linux

Source: Internet
Author: User
Tags openssl enc openssl md5 openssl sha1

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:

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.