Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to generate, encrypt or decrypt random passwords under Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to generate, encrypt or decrypt random passwords under Linux. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.

1. Use the command pwgen to generate a unique random password of 10 characters in length. If you don't already have pwgen installed, install it using a package manager such as Apt or YUM.

$ pwgen 10 1

Generate a unique random password

Generate unique random passwords of 50 characters in one breath!

$ pwgen 50

Generate multiple random passwords

2. You can also use makepasswd to generate unique random passwords of a given length one at a time. Before you play with the makepasswd command, make sure you have it installed. If it is not installed, try installing the makepasswd package using Apt or YUM package manager.

Generates a random password of 10 characters in length. The password length generated by this command defaults to 10.

$ makepasswd

Use makepasswd to generate unique passwords

Generates a random password of 50 characters in length.

$ makepasswd --char 50

Generate a password of length 50

Generates 7 random passwords of 20 characters in length.

$ makepasswd --char 20 --count 7

3. Use Crypt with salt to encrypt a password. Manual or automatic addition of "salt" is available.

For those of you who don't know what salt means, salt here refers to a random piece of data that serves as an extra input to a password generation function designed to protect passwords from dictionary attacks.

Make sure you have mkpasswd installed before you do the following.

The following command encrypts a password with salt. The value of Salt is automatically generated randomly. So each time you run the following command, it will produce a different output because it receives a random value of "salt" each time.

$ mkpasswd tecmint

Use Crypt to encrypt passwords

Now let's manually define the value of Salt. Each time it produces the same result. Note that you can enter any value you want for salt.

$ mkpasswd tecmint -s tt

with "salt" encryption code

In addition, mkpasswd is interactive and will ask you for your password if you don't include it in the command.

4. Encrypt a string (such as "Tecmint-is-a-Linux-Community") using the aes-256-cbc encryption algorithm and using a password with "salt"(such as "tecmint").

# echo Tecmint-is-a-Linux-Community | openssl enc -aes-256-cbc -a -salt -pass pass:tecmint

Encrypting a String in Linux

In the example above, the output of the echo command is piped to the openssl command, causing the output to be encrypted using enc (Encoding with Cipher ), which uses the aes-256-cbc encryption algorithm, along with the tecmint and salt.

5. Use the-aes-256-cbc decryption option of the openssl command to decrypt the above string.

# echo U2FsdGVkX18Zgoc+dfAdpIK58JbcEYFdJBPMINU91DKPeVVrU2k9oXWsgpvpdO/Z | openssl enc -aes-256-cbc -a -d -salt -pass pass:tecmint

Decrypting strings in Linux

About "how to generate, encrypt or decrypt random passwords under Linux" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report