Issue
I'm writing a bash script which compresses (with encryption or without, depending on what the user chooses) and decompresses files using zip. My problem is the decompressing part - when the user chooses a zip file to decompress (via zenity file selection), is there any way to check if the file is password protected in order to ask the user for the password (or if it isn't, just proceed and decompress the file)?
I didn't really try anything yet, as I've struggled to come up with any idea or find a solution on stack and other websites.
Solution
if 7z l -slt file.zip | grep -q ZipCrypto; then
echo "password protected / encrypted"
else
echo "no password protection / not encrypted"
fi
See: How to detect zip file encryption algorithm
Answered By - Cyrus Answer Checked By - David Marino (WPSolving Volunteer)