background
Recently, some files need to be encrypted, but there is no corresponding encryption tool on the Mac. Creating password-protected compressed zip files in macOS is easy and does not require any additional add-ons or downloads. You can do it with the command line. Encrypting the archive means that when someone wants to unzip the zip file, they must enter the correct password to get out of the archive.
Order
Enter the password when compressing the file
zip -e [archive] [file]
In this case, the resulting archive name is "archivename.zip", while password encryption is provided. The "filetoprotect.txt" file is now encrypted and does not allow access without entering a password.
[@MacBook-Pro:Downloads]$ zip -e payForMe.zip 职场老实人.jpg
Enter password:
Verify password:
adding: 职场老实人.jpg (deflated 6%)
unzip files
unzip filename.zip
example
[@MacBook-Pro:Downloads]$ unzip payForMe.zip
Archive: payForMe.zip
[payForMe.zip] ???????????人.jpg password:
replace ???????????人.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: yes
inflating: ???????????人.jpg
deflated: deflated - compression
inflating: inflation - decompression
If this article is helpful to you, please give "Lingye Jun" a thumbs up, thank you for your support.
First link: https://www.cnblogs.com/lingyejun/p/17539329.html