Example: encryption and decryption of compressed files (read + OpenSSL + tar + dd)

Source: Internet
Author: User

1. Some files need to be encrypted.

2. Some folders need to be encrypted.


Analysis:

What are the considerations for file or folder encryption?

Folder auto-completion full-time suffix with backslash processing rules

Naming rules for encryption of a single file

> The script command format is./SS {unencryptfile | unencryptdir}

> First, determine whether the first parameter is a file or a folder.

1. Folder

> Check whether a folder has a backslash.

> Use the folder name as the name of the generated compressed package

2. File time

> The file Suffix in Linux is removed during encryption.

> The suffix makes sense when compression and decompression are used.

> Use the file name as the compressed package name


Example:

------- Encrypt-> Generate .tar.bz2or .tar.gz compressed file -------

$ Vim tar. Encrypt

#! /Bin/bash


Read-P "input compress cipher key:" ARGs # indicates the input compression key.


# The way I

# Tar-zcf-$1 | OpenSSL des3-salt-K $ ARGs | dd of1_1_1.tar.gz encrypted to generate .tar.gz compression format

Tar-JCF-$1 | OpenSSL des3-salt-K $ ARGs | dd of1_1_1.tar.bz2 encrypted to generate .tar.bz2 compression format


# The way II works with wayI

# Tar-zcf-$1 | OpenSSL des3-salt-K $ ARGs-out release 1.tar.gz

# Tar-JCF-$1 | OpenSSL des3-salt-K $ ARGs-out rules 1.tar.bz2


------- Decrypt-> Generate a file or folder -------

$ Vim tar. decipher

#! /Bin/bash


Read-P "input decompress cipher key:" ARGs # enter the decryption key


# The way I works with wayii

# Dd If = $1 | OpenSSL des3-D-K $ ARGs | tar-zxf-

# Dd If = $1 | OpenSSL des3-D-K $ ARGs | tar-jxf-


# The way II

# OpenSSL des3-D-K $ ARGs-salt-in $1 | Extract files in .tar.gz format from tar-zxf-release

OpenSSL des3-D-K $ ARGs-salt-in $1 | Extract files in .tar.bz2 format from tar-jxf-compression


Note:

No parameter quantity limit is added.


This article is from the "andyhdchoice" blog, please be sure to keep this source http://andyhdchoice.blog.51cto.com/1521623/1548788

Example: encryption and decryption of compressed files (read + OpenSSL + tar + dd)

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.