不知道這是爲什麼失敗..使用OpenSSL打亂做文件比較
./testme.sh
Before Loop
SSL1: /root/a.txt SHA256(/root/a.txt)= 92b165232fbd011da355eca0b033db22b934ba9af0145a437a832d27310b89f9
SSL2: /root/b.txt SHA256(/root/b.txt)= f0f9c277cf17429957daf6594714cc5470ac5c474ba5ac50319185477a174799
different
cp a.txt b.txt
./testme.sh
Before Loop
SSL1: /root/a.txt SHA256(/root/a.txt)= 92b165232fbd011da355eca0b033db22b934ba9af0145a437a832d27310b89f9
SSL2: /root/b.txt SHA256(/root/b.txt)= 92b165232fbd011da355eca0b033db22b934ba9af0145a437a832d27310b89f9
different
校驗和相同,但不同的報道:|
#!/bin/bash
#
# OPENSSL=/usr/bin/openssl
OPENSSL=/usr/local/openssl/bin/openssl
HOME=/root
ENCRYPT=sha256
SSL1=$($OPENSSL $ENCRYPT $HOME/a.txt)
SSL2=$($OPENSSL $ENCRYPT $HOME/b.txt)
## DEBUG
echo "SSL1: $HOME/a.txt $SSL1"
echo "SSL2: $HOME/b.txt $SSL2"
if [ "$SSL1" = "$SSL2" ]
then
echo "same"
else
echo "different"
fi
如果我使用sha256sum代替,是否需要更改? – 2012-03-17 06:10:21
嗯,sha256sum文件|砍掉-d''-f1 – 2012-03-17 06:36:50