zip -er target_archive.zip source_folder
Enter your password. The Terminal will prompt you to type a password and then verify it by typing it again.
Note: No text or asterisks will display while you type your password. This is a normal Unix security feature; just type the password blindly and hit Return.
-e: Tells the system to encrypt the file (add a password).-r: Tells the system to act recursively so it includes all files inside your folder.target_archive.zip: The name you want to give to your final password-protected ZIP file.source_folder: The actual name of the folder or file you want to compress.