Files
pcp/tests/check-collisions.sh
2013-10-28 22:50:05 +01:00

32 lines
579 B
Bash
Executable File

#!/bin/sh
rounds=$1
if test -z "$rounds"; then
rounds=10
fi
make check
log="collisions.log"
name=""
echo "Checking collisions for hash algorithms with ${rounds} rounds:" > $log
for hash in c o f d s; do
case $hash in
o) name="OAT";;
c) name="CRC";;
s) name="SAX";;
d) name="DJB";;
f) name="FNV";;
esac
echo -n "Running ${rounds} x ${name} hash ... "
echo -n "Collisions for ${name}: " >> $log
./col -l ${rounds} -${hash} \
| sort | uniq -c | sort | grep -v "1 " | wc -l \
>> $log
echo "done."
done
echo
echo "Review $log for the results."