In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
As the project needs to encrypt and decrypt the file in the process of transmission, so look up the relevant introduction of encryption and decryption on the Internet, and at first use the RSA encryption and decryption algorithm, first using RSAEuro to toss about the compilation for half a day and get stuck (the reason for the compilation error can not be found out). Later, it is found on the Internet that the implementation method using openssl is relatively simple.
OpenSSL is a powerful encryption toolkit that integrates many cryptographic algorithms and utilities. It is easy to encrypt and decrypt with rsa algorithm, but it can only deal with small data files (personal opinion), and other algorithms are needed to deal with large file data.
For relevant operation commands about RSA algorithm, please refer to:
Http://www.cnblogs.com/aLittleBitCool/archive/2011/09/22/2185418.html
Now introduce the use of openssl's aes algorithm to encrypt and decrypt big data files, I wrote a shell script, as follows
Encrypt encrypt.sh, where KEYFILE= "enc.key" is a 16-character password file
#! / bin/sh# function: file encryption if [$#-ne 2] then echo usage: $0 File name to be encrypted "echo" for example: $0 hello hello.en "whether the encrypted file name entered by exit 1fi#flag is the same as the encrypted file name, 1 is the same file name flag=0KEYFILE=" enc.key "INFILE=$1OUTFILE=$2if [- f $INFILE] then echo" start encrypting $INFILE "else echo" error: the file does not exist! Exit 1fiif ["$INFILE" = "$OUTFILE"] then OUTFILE=$2.TMP flag=1fi# encrypts files openssl enc-e-aes-128-cbc-kfile $KEYFILE-in $INFILE-out $OUTFILEif [$?-eq 0] then if [flag-eq 1] then mv $OUTFILE $INFILE echo "encryption complete! generate encryption file as $INFILE" else echo "encryption complete! generate encryption file as $OUTFILE" fielse echo "error: encryption failed! Fiexit 0
Decrypt decrpt.sh
#! / bin/sh# function: file decryption if [$#-ne 2] then echo usage: $0 the name of the decrypted file to be decrypted "echo" for example: $0 hello.en hello.de "exit 1fixes decrypted 0KEYFILEE =" enc.key "INFILE=$1OUTFILE=$2if [- f $INFILE] then echo" start decrypting $INFILE "else echo" error: the file does not exist! Exit 1fiif ["$INFILE" = "$OUTFILE"] then OUTFILE=$2.TMP flag=1fi# decrypts the file openssl enc-d-aes-128-cbc-kfile $KEYFILE-in $INFILE-out $OUTFILEif [$?-eq 0] then if [flag-eq 1] then mv $OUTFILE $INFILE echo "decryption complete! generate decryption file as $INFILE" else echo "decryption complete! generate decryption file as $OUTFILE" fielse echo "error: decryption failed! Fiexit 0
For reference only, if you have any questions, please correct them, thank you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.