If you need to check if zip or rar file has password protection you can do it this way.
For zip fip:
crypted=$( 7z l -slt -- $file | grep -i -c "Encrypted = +" ) if [ "$crypted" -eq "1" ]; then protected=1 fi
And for rar:
unrar x -p- -y -o+ "$file" 1> /dev/null 2> /dev/null if [ "$?" -eq "3" ] ; then unrar x -p$password -y -o+ "$file" 1> /dev/null 2> /dev/null fi
Didn’t find the answer to your question? Ask it our administrators to reply we will publish on website.