亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Install the tool before encrypting with GPG
Simple encryption of a single file (symmetric encryption)
Send encrypted files to others? Asymmetric encryption is more appropriate
Tip: Don’t forget to clean up plain text files

How to use GPG for file encryption

Oct 14, 2025 am 04:59 AM

Encrypting files is actually not difficult, you can do it with GPG. GPG is an open source encryption tool that supports symmetric and asymmetric encryption methods and is suitable for protecting local files or securely exchanging data; 1. When installing GPG, Linux users can use the package manager, such as sudo apt install gnupg for Ubuntu, Homebrew for macOS: brew install gnupg, and Windows can download the installation package or use Gpg4win; 2. Check the version number and use gpg --version to ensure successful installation; 3. To symmetrically encrypt a single file, use gpg -c filename.txt, decrypt using gpg -o decrypted.txt -d filename.txt.gpg; 4. For asymmetric encryption, you need to import the other party’s public key and use gpg -e -r someone@example.com to encrypt filename.txt, and the other party uses gpg -o original.txt -d received_file.gpg decryption; 5. Clean the plain text files after encryption, and it is recommended to package and compress multiple files before encryption and then encrypt.

How to use GPG for file encryption

Encrypting files is actually not difficult, you can do it with GPG (GNU Privacy Guard). It is an open source encryption tool that supports symmetric and asymmetric encryption methods and is suitable for protecting local files or exchanging data securely with others.


Install the tool before encrypting with GPG

Whether you are using Linux, macOS or Windows, GPG has a corresponding version. Linux users can generally install through a package manager, such as on Ubuntu:

 sudo apt install gnupg

Homebrew can be used on macOS:

 brew install gnupg

For Windows, you can download the installation package from the official website, or use Gpg4win. After installation, it is recommended to check the version number:

 gpg --version

Make sure the installation is successful and you see a list of supported algorithms in the output.


Simple encryption of a single file (symmetric encryption)

If you just want to encrypt a file for yourself and don't want to make it too complicated, you can directly use symmetric encryption. That is, set a password and use this password to decrypt later.

The operation command is as follows:

 gpg -c filename.txt

After execution, you will be prompted to enter and confirm your password. After completion, a filename.txt.gpg file will be generated. The original file is still there and you can delete it manually.

Decryption is also very simple:

 gpg -o decrypted.txt -d filename.txt.gpg

It will ask you to enter a password, which if correct will restore the original content.


Send encrypted files to others? Asymmetric encryption is more appropriate

If you want to encrypt a file and send it to someone else, and the other party can decrypt it with their own private key, then you need to use asymmetric encryption. This requires you to have the other party's public key.

First import the other party’s public key:

 gpg --import their_public_key.asc

Then see what keys are available:

 gpg --list-keys

Find the person you want to encrypt to. Assuming his email is someone@example.com , you can encrypt it like this:

 gpg -e -r someone@example.com filename.txt

This will generate a filename.txt.gpg file, which can only be unlocked by those with the corresponding private key.

If the other party wants to decrypt the file after receiving it, just run:

 gpg -o original.txt -d received_file.gpg

This assumes they have imported their private key.


Tip: Don’t forget to clean up plain text files

Just because encryption is complete doesn’t mean everything is fine. Remember to delete the original file, otherwise others can still open it and view the content directly. Deleting files on some systems cannot completely clear them. You can use shred or special tools to overwrite the disk space.

In addition, if it is sensitive data, it is recommended to package it into a compressed package and then encrypt it before encryption, for example:

 tar -czf files.tar.gz file1 file2
gpg -e -r someone@example.com files.tar.gz

This is also convenient for uploading multiple files at once.


That's basically it. GPG has many functions, but the above methods are enough for daily encryption of files.

The above is the detailed content of How to use GPG for file encryption. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

How to remove a package using yum How to remove a package using yum Sep 21, 2025 am 06:15 AM

Toremoveapackageusingyum,usethecommandsudoyumremovepackage_name,whichremovesthepackageandpotentiallyitsunuseddependencies.Beforedoingso,ensureyouhavethecorrectpackagenamewithyumlistorrpm-q,checkdependenciesviayumdeplist,andavoidremovingcriticalsystem

How to check system logs How to check system logs Sep 19, 2025 am 02:56 AM

To view the system log, you need to select the corresponding tool according to the operating system. Windows uses event viewer, with the path to Win R, enter eventvwr.msc, to view the "System" classification under "Windows Log", and supports filtering and saving; Linux system logs are usually located in /var/log/ directory, such as syslog, messages, dmesg files, and can be viewed by tail-f or journalctl-u service name commands; Mac can view logs through the Console application or logshow command. When viewing, you should pay attention to error and warning level information, analyze problems based on timestamps and context, and pay attention to permission requirements.

How to use network namespaces How to use network namespaces Sep 17, 2025 am 05:16 AM

To create and use a network namespace, you need to create it first, then assign the interface and IP, and set up the routing to achieve communication. The steps are as follows: 1. Create a namespace with ipnetnsadd; 2. Create a vethpair through iplinkadd and move one end into the namespace; 3. Assign IP to the interface and enable it; 4. If you need external network access, enable IP forwarding, configure iptablesMASQUERADE and set default routes; 5. Close the interface first and clean the rules when deleting. The entire process needs to pay attention to resource cleaning and rule consistency.

How to synchronize system time using NTP How to synchronize system time using NTP Sep 21, 2025 am 05:54 AM

To ensure that the system time synchronization is reliable, first make sure that the NTP service is installed and run, use systemctl to check the state of ntp or chronyd, and start and set up the power-on self-start if necessary. Secondly, configure a suitable NTP server, modify the /etc/ntp.conf or /etc/chrony/chrony.conf file, and recommend choosing a server with a similar geographical location such as Alibaba Cloud or Tencent Cloud. Finally, check the synchronization status and use ntpq-p or chronycsources to view the connection status. If the offset is too large, you can use ntpdate to manually calibrate it, but long-term synchronization should rely on background services to ensure stability.

How to find which process is using a file How to find which process is using a file Sep 20, 2025 am 04:22 AM

When a file is occupied, you can search and end the occupied process by the following methods: 1. The Windows system can use the task manager to search for file handles with the resource monitor; 2. Use the handle.exe tool of Sysinternals to query accurately, requiring administrator permission; 3. Linux/macOS uses the lsof command to search for keywords, and grep can search for keywords; 4. Before ending the process, you must confirm the purpose. Windows can use the task manager or taskkill command, and Linux/macOS can use the kill command to avoid killing the system process by mistake.

How to partition a disk using parted How to partition a disk using parted Sep 19, 2025 am 04:31 AM

The key to using parted partition disks is to master several steps: 1. Preparation: Confirm the target disk device name (such as /dev/sdb) and judge its partition table type. If it is less than 2TB, use MSDOS (MBR) and if it is greater than 2TB, use GPT; 2. Create a partition table: After entering parted operation mode, execute the mklabel command to select gpt or msdos, this step will clear the disk data; 3. Start partition: Use the mkpart command to specify the partition type, file system and start and end location, such as mkpartprimaryext40GB50GB, and continue to add other partitions; 4. Format and mount the partition: manually execute mkfs.ext4 and other commands to format,

How to write a simple bash script How to write a simple bash script Sep 20, 2025 am 05:38 AM

Writing a simple Bash script is actually not that difficult. You can get started quickly by mastering a few basic structures and commands. 1. Each script should start with #!/bin/bash, and then run after adding execution permissions through chmod x; 2. The variables are assigned directly without declaration, and they are referenced by $ variable name or ${ variable name}, and use the read command to achieve input interaction; 3. The commonly used if judgment and for/while loops in the control process, pay attention to the difference between spaces before and after square brackets and comparison operators; 4. Practical techniques include debugging parameters - x, using absolute paths, adding comments to improve readability, and indicating successful ending by exit0. After mastering these core points, practice more to write Bash scripts proficiently.

How to troubleshoot disk IO bottlenecks How to troubleshoot disk IO bottlenecks Sep 17, 2025 am 06:50 AM

When encountering a disk IO bottleneck, you should first confirm the root cause of the problem and then optimize it. 1. Use iostat, iotop and other tools to confirm whether there are IO bottlenecks, pay attention to %util and await indicators; 2. Analyze application behavior, reduce small files reading and writing, enable file system cache, and optimize log writing methods; 3. Select a suitable file system such as ext4 or XFS to improve IO efficiency; 4. Adjust the IO scheduling strategy, choose noop or deadline in SSD, and use CFQ in mechanical hard disks; 5. Use cache (such as Redis) and asynchronous IO mechanism to reduce disk pressure.

See all articles