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)