How to use OpenSSL to encrypt and decrypt files
1. Use openssl to encrypt a file (data.zip is the original file, back.zip is the encrypted file)
# openssl enc -e -aes256 -in data.zip -out back.zip
Explanation: enc means symmetric encryption or decryption of files, -e means encryption of a file, -aes256 means encryption using the aes256 algorithm, -in means the file that needs to be encrypted, -out means the file generated after encryption new file. During the encryption process, you will be asked to enter an encryption password. Enter it twice to complete the encryption of the file
2. Use openssl to decrypt a file (back.zip is the encrypted file, data.zip is the decrypted file)
# openssl enc -d -aes256 -in back.zip -out data.zip
Explanation: enc means symmetric encryption or decryption of the file, -d means decryption of the file, -aes256 means decryption using the aes256 algorithm, -in means the file that needs to be decrypted, -out means the new file generated after decryption file, when decrypting a file, you will be asked to enter the password set when encrypting the file to decrypt it.
1. First you need to use openssl to generate a 2048-bit key rsa.key file (rsa.key key file contains the private key and public key)
# openssl genrsa -out rsa.key 2048
2. Then extract the public key pub.key
from the rsa.key key file# openssl rsa -in rsa.key -pubout -out pub.key
3. Use the pub.key public key to encrypt a file (data.zip is the original file, back.zip is the encrypted file)
# openssl rsautl -encrypt -inkey pub.key -pubin -in data.zip -out back.zip
4. Use the rsa.key private key to decrypt a file (back.zip is the encrypted file, data.zip is the decrypted file)
# openssl rsautl -decrypt -inkey rsa.key -in back.zip -out data.zip
Finally, we use the OpenSSL tool to encrypt and store all backup data files to ensure that the business system data is protected and leaked. We can also use other encryption tools such as GPG, VeraCrypt, and trueCrypt to encrypt data, but in comparison, using OpenSSL is more convenient because almost every Linux distribution comes with the OpenSSL software package pre-installed.
The above is the detailed content of How to use OpenSSL to encrypt and decrypt files. For more information, please follow other related articles on the PHP Chinese website!

Portable Document Format (PDF) remains a widely used file format due to its consistent standards across different platforms and devices, compatibility, and compact size.Numerous powerful tools are available for viewing PDF files, catering to various

Linux Mint 22, codenamed “Wilma”, was officially launched as a significant update to Linux Mint on July 25, 2024. Linux Mint 22 is an LTS (Long Term Service) release, built upon Ubuntu 24.04, and will receive support until April 2029.As anticipated,

Passwords serve as the primary security measure across various systems, including Linux, where the root password grants full control over the system. They are essential for securing BIOS, login, disks, applications, and more.Linux is widely regarded

Data encryption is an essential component of modern cybersecurity, enabling the encoding of data to render it unreadable to unauthorized users. To enhance your online security, consider choosing software that incorporates this vital feature as a stan

Linux Mint 22, with the codename “Wilma”, has been officially launched and is ready for download. Built on Ubuntu 24.04, it offers support until 2029 and comes in three flavors: Cinnamon, MATE, and XFCE.This guide will take you through the steps to i

The term "cloud" evokes a sense of vastness and expansiveness. In the technology sector, "the cloud" denotes a virtual platform that delivers services to end-users, encompassing data storage, application hosting, and the virtualiz

Linux Mint is a contemporary, user-friendly, and community-driven GNU/Linux desktop distribution, built on the well-known Ubuntu Linux distribution. It's an excellent choice for users transitioning from Windows or macOS to the Linux environment.Linux

Introduction: In this article, you will find the best applications for creating PDF files (also known as interactive tables) on Linux. If you need powerful tools to create and edit PDF files on Linux, you have many applications to choose from. These applications are able to perform basic editing operations such as merging pages, cropping pages, adding comments, and sometimes even providing advanced features. However, not all PDF editors can create PDF forms—that is, editable PDF files with interactive fields that can be filled in by other users. Such documents are useful in situations like you need to create a questionnaire, an admission form, or a sales contract, etc. The following list includes solutions that can run on various Linux distributions,


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
