How to encrypt compressed files the easy way from Windows, macOS, or Linux


Learn to secure multiple documents by encrypting compressed files on various OSes using a password.

Image: Meilun, Getty Images/iStockphoto

When considering how to share data efficiently, cloud storage has a leg up on hardware by making it easy to share files and folders with users across the globe with a few clicks. Because the data is only transmitted from server to client provides little impact on bandwidth for the sender and recipient. But storing data on the cloud is not the most secure practice since that data is effectively placed in the hands of a third party.

SEE: COVID-19: A guide and checklist for restarting your business (TechRepublic Premium)

This is especially true of data that is sensitive or confidential in nature. The trade-off is that this type of data should be shared directly between those who require access to it and no one else. By using compressed file types, such as ZIP, a sender can place multiple documents, including entire directories, together and compress them as a single file making it easy to share, while using strong algorithms to encrypt the contents based on a password that only the recipients will know.

While this technology has existed for decades, modern OSes typically focus on cloud-based sharing services when providing options for users to share data. But that native functionality is present in Windows, macOS, and Linux, and can be accessed simply by entering a few commands into the CLI. Follow below as we go over the steps to perform this on each platform.

Linux and macOS

  1. Launch the Terminal. 
  2. Change directories to where you want the compressed file saved to.
  3. Enter the following command using the -e switch to encrypt the resulting compressed file and -r to recurse subdirectories (if available):
    zip -er Filename.zip /path/to/files
  4. Enter the password when prompted, then again to verify.
  5. The resulting ZIP file will be saved to the chosen directory once the command has completed processing.

Windows

Windows supports creating compressed files via PowerShell from v5.0+, however, while it natively supports ZIP creation it does not support encryption and has a file limit of just 2GB. In the interest of simplicity and for the purposes of this article, I recommend leveraging the 7-zip module for PowerShell to get around these limitations.

  1. Launch PowerShell with administrative escalation.
  2. Install the 7-zip module by entering the cmdlet below. It does query the PS gallery and uses a third-party repository to download the dependencies. If you’re OK with the security considerations, approve the installation to proceed:
  3. Install-Module -Name 7zip4PowerShell -Verbose
  4. Change directories to where you want the compressed file saved.
  5. Create a secure string for your compressed file’s encryption by entering the cmdlet below:
  6. $SecureString = Read-Host -AsSecureString
  7. Enter the password you wish to use in PowerShell. The password will be obfuscated by asterisks. The plain text entered will be converted to $SecuresString, and you’ll use that in the next step.
  8. Enter the following cmdlet to encrypt the resulting compressed file: 
  9. Compress-7zip -Path "pathtofiles" -ArchiveFileName "Filename.zip" -Format Zip -SecurePassword $SecureString
  10. The resulting ZIP file will be saved to the chosen directory once the command has completed processing.

Also see



Source link