#!/usr/local/bin/tcsh -f

# ISE test script 22

# Decrypt_File Function with Incorrect Key

rm decrypted_images/*
set image_count = 0
set failure_count = 0
echo "Test 22: testing decrypt file with incorrect key on all .jpg images inside directory 'images'"

foreach ise_file (ise_images/*.ise)
	ise_test_22 $ise_file
	@ image_count += 1
	if ($image_count == 100) then
	    echo "...still working"
	    @ image_count = 0
	endif
end

mv ise_images/*.jpg decrypted_images/.
chmod 777 decrypted_images/*.jpg

foreach jpeg_file (images/*.jpg)
    set decrypted_file = decrypted_$jpeg_file
    cmp -s $jpeg_file $decrypted_file
    if ($status == 0) then
        echo "Test 22: Images are identical for"$jpeg_file
	@ failure_count += 1
    endif
    @ image_count += 1
    if ($image_count == 100) then
	echo "...still working"
	@ image_count = 0
    endif
end

if ($failure_count == 0) then
    echo "Test 22 Passed for all images."
else
    echo "Test 22 Passed for all other images."
endif

exit 0

###############
# END OF FILE #
###############
