In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
Vim is a popular, feature-rich and highly extensible Linux text editor. One of its special functions is to support various encryption methods with passwords to encrypt text files.
In this article, we will introduce you to a simple technique for using Vim: using Vim to password protect files in Linux. We will show you how to secure a file when it is created and after it is opened for modification purposes.
To install the full version of Vim, simply run these commands:
$sudo apt install vim # Debian/Ubuntu system $sudo yum install vim # RHEL/CentOS system $sudo dnf install vim # Fedora 22 +
How to use Vim to protect files with password in Linux
Vim has a-x option that allows you to use it to encrypt files when you create them. Once you run the following vim command, you will be prompted to enter a key:
$vim-x file.txt warning: weak encryption method is being used; see: help 'cm' enter encryption key: * enter the same key again: *
If the key entered the second time is correct, you can modify this file.
Password-protected Vim files
After you have modified it, press Esc and type: wq to save and close the file. The next time you want to open it and edit it, you have to enter the key like this:
$vim file.txt requires encryption key for "file.txt" warning: weak encryption method is being used; see: help 'cm' input key: *
Suppose you type a wrong password (or no password) and you will see some junk characters.
Encrypted content in Vim
Set up a strong encryption method in Vim
Note: the warning indicates that the file is protected by a weak encryption method. So next, let's look at how to set up a strong encryption method in Vim.
Weak encryption of Vim Chinese text
To view the encryption method (cm) set, type:
: help 'cm'
Sample output:
* 'cryptmethod'* *' cm'*'cryptmethod' string (default "zip") global or local to buffer | global-local | {not in Vi} encryption method used when the buffer is written to the file: * pkzip* zip PkZip compatible method. A weak encryption method. Backward compatibility with Vim 7.2 and older. * blowfish* blowfish puffer fish encryption. The intermediate strength encryption method has some defects in implementation. Vim 7.3or above is required, and files encrypted with it cannot be read by Vim 7.2or older. It adds a "seed", which is different every time you write to a file.
You can set a new encryption method for a Vim file as shown below (in this case we use the blowfish3 encryption method)
: setlocal cm=blowfish3
Then type enter and: wq to save the file.
Set strong encryption to Vim files
Now you should not see that warning message when you open the file below.
$vim file.txt requires the encryption key of "file.txt" to enter the encryption key: *
You can also set the password after opening the Vim file, and use the: X command to set an encrypted password as shown above.
Summary
This is the end of this article! In this article, we introduced how to use the Vim text editor under Linux to protect a file from encryption.
Always remember to use strong encryption and passwords to properly protect text files that may contain confidential information such as usernames and passwords, financial account information, etc.
The above is the whole content of this article, I hope that the content of this article can bring some help to your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
Via: https://www.tecmint.com/password-protect-vim-file-in-linux/
Author: Aaron Kili translator: ch-cn proofread: wxy
This article was originally compiled by LCTT and honored by Linux China.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.