#! /bin/sh FILE="test_file" TMP="test_tmp" KEY="secret_key_yeah_" # 16 bytes for twofish BIN="./cryptot" if [ ! -x ${BIN} ]; then echo "" && exit 1; fi; # 80 Mb file echo "generate a 70Mb file from source files." if [ -f ${FILE} ]; then rm ${FILE}; fi; if [ -f ${TMP} ]; then rm ${TMP}; fi; cat *.c > ${FILE}; cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && \ cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && \ cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} && \ cat ${FILE} >> ${TMP} && cat ${TMP} >> ${FILE} || exit 1; echo "done." rm ${TMP} ARGS1="-v -c 1 -n 700 " ARGS2="-v -x -c 1 -n 600 " ARGSD="-d 127.0.0.1:4779" ARGSS="-s 127.0.0.1:4779" local(){ cat ${FILE} | ${BIN} ${ARGS1} ${KEY} | ${BIN} -x ${ARGS2} ${KEY} > DEC } dist (){ ${BIN} -x ${ARGS2} ${ARGSS} ${KEY} > DEC & PID=$! sleep 2 cat ${FILE} | ${BIN} ${ARGS1} ${ARGSD} ${KEY} || ( echo "error !!"; exit 1 ) wait ${PID} } local echo "running diff" diff ${FILE} DEC || echo "ERROR" echo "OK." rm DEC dist echo "running diff" diff ${FILE} DEC || echo "ERROR" echo "OK." rm DEC ${FILE}