Let's use 7zip for strong AES256 encrypted archives with a password. The guide assumes you're on Ubuntu 22 or newer. Note: this creates .7z archives, which is not the same as the regular .zip!
# Install 7zip. Note: don't install "p7zip-full" or "p7zip" (it's an older version!)
# Source, version things: https://askubuntu.com/questions/1465853/difference-between-several-command-line-tools-provided-for-7-zip-compression-li
sudo apt update
sudo apt install 7zip
# Manual install of latest version from here: https://www.7-zip.org/download.html
# --> download tar file and untar. You get a binary 7zz
tar xvxf ./7z2407-linux-x64.tar.xz # this untars all files into current folder. watch out!
sudo mv ./7zz /usr/local/bin/7z
# --> Version used here
7z --help
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
64-bit locale=en_US.UTF-8 Threads:18 OPEN_MAX:1024
# --> Create encrypted archive with sensible defaults (-p makes it ask for a password)
# The command works recursively on subfolders, too.
7z a \
-t7z -m0=lzma2 -mx=9 -mfb=64 \
-md=32m -ms=on -mhe=on -p \
archive_name.7z ./my_folder
# --> Extract the archive to a non-existing output folder my_output (created when this is run)
7z x archive_name.7z -o./my_output
# Alternative, encrypt as zip using aes256
7z a -tzip -p -mem=AES256 nice_file.zip file_i_want_encrypted.txt
Bonus, view technical specs of archive:
# Command to check specs
7z l -slt archive_name.7z Py sleepy
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
64-bit locale=en_US.UTF-8 Threads:18 OPEN_MAX:1024
Scanning the drive for archives:
1 file, 943200 bytes (922 KiB)
Listing archive: archive.7z
Enter password (will not be echoed): # <- you need to enter password again, here
--
Path = archive_name.7z
Type = 7z
Physical Size = 94320
Headers Size = 832
Method = LZMA2:1536k 7zAES # <- 7zAES means AES256 encryption
Solid = +
Blocks = 1