加密:
tar -czvf - mcw.txt | openssl des3 -salt -k '<a?VU<a{sfm*sf1' -out xiaoma.des3
解密:
openssl des3 -d -k '<a?VU<a{sfm*sf1' -salt -in xiaoma.des3 | tar xzvf -
➜ machangwei mkdir mcwtest ➜ machangwei cd mcwtest ➜ mcwtest cp ../mcw.txt . ➜ mcwtest ls mcw.txt ➜ mcwtest cat mcw.txt mcw ➜ mcwtest tar -czvf - mcw.txt | openssl des3 -salt -k '<a?VU<a{sfm*sf1' -out xiaoma.des3 #加密, a mcw.txt ➜ mcwtest ls mcw.txt xiaoma.des3 ➜ mcwtest head -a xiaoma.des3 head: invalid option -- a usage: head [-n lines | -c bytes] [file ...] ➜ mcwtest head -1 xiaoma.des3。#查看加密后文件,是乱码的 �39��t��y���= ��nb�3�Cn���-g`{(1t�+J��n]�"�]�+%=.2�ٔl�BL)�1/�7��Xf:���Ҵ!SI%?��D@�9�|���J��S�9#�ǯ�݈>w��D=� �kr d�Q��%��ݲȜ��©Q$�n�^�}f�8����"�s����o�I&�;d��>y��sp�`��W*$� ➜ mcwtest mkdir m ➜ mcwtest cp xiaoma.des3 m ➜ mcwtest cd m ➜ m ls xiaoma.des3 ➜ m openssl des3 -d -k '<a?Vssss' -salt -in xiaoma.des3 | tar xzvf - #解密式 -k不对,验证通不过 bad decrypt 4784133804:error:06FFF064:digital envelope routines:CRYPTO_internal:bad decrypt:/AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/libressl/libressl-2.8/crypto/evp/evp_enc.c:521: tar: Error opening archive: Unrecognized archive format ➜ m openssl des3 -d -k '<a?VU<a{sfm*sf1' -salt -in xiaoma.des3 | tar xzvf - #解密 x mcw.txt ➜ m ls mcw.txt xiaoma.des3 ➜ m cat mcw.txt #解密后,加密时的文件出来了,并且内容可以正常查看。 mcw ➜ m
标签:文件,openssl,加密,解密,des3,mcwtest,mcw,txt From: https://www.cnblogs.com/machangwei-8/p/17715143.html