10 methods for generating random passwords in Linux and 10 methods for generating random passwords in linux

Source: Internet
Author: User

10 methods for generating random passwords in Linux and 10 methods for generating random passwords in linux

A major advantage of Linux is that you can implement the same thing in hundreds of ways. For example, you can generate a random password in dozens of ways. This article describes ten methods to generate a random password.

1. Use the SHA algorithm to encrypt the date and output the first 32 characters:

  1. Date + % s | sha256sum | base64 | head-c 32; echo

The result is as follows:

  1. ZTNiMGM0NDI5OGZjMWMxNDlhZmJmNGM4

2. Use embedded/dev/urandom and filter out characters that are not commonly used.. Here, only the first 32 characters of the output result are returned:

  1. </Dev/urandom tr-dc _ A-Z-a-z-0-9 | head-c $ {1:-32}; echo

The result is as follows:

  1. PDj0Xwz7exD_Qb5B27BwWsM1hrF3a7cJ

3. Use Random Functions of openssl

  1. Openssl rand-base64 32

The result is as follows:

  1. RYJWqJlTLAYeX3j7nCbir20h1k/0 CnqLNEuNyTScfKo =

4. This method is similar to the previous urandom.But it works reversely.

  1. Tr-cd '[: alnum:]' </dev/urandom | fold-w32 | head-n1; echo

The result is as follows:

  1. TpgudzF7sqtU4yyW2LVhmUQOZIQi87

5. Use the string commandWhich outputs printable strings from a file

  1. Strings/dev/urandom | grep-o '[[: alnum:]' | head-n 32 | tr-d '\ n'; echo

The result is as follows:

  1. W4v1iqtkmq8sidd9jxdqnpg8hp1_8

6. This is a simpler version of urandom.

  1. </Dev/urandom tr-dc _ A-Z-a-z-0-9 | head-c32; echo

The result is as follows:

  1. RMDlGSPN_bm-IZVFWz9BEi0rF-jIy6gs

7. Use a very useful dd command

  1. Dd if =/dev/urandom bs = 1 count = 32 2>/dev/null | base64-w 0 | rev | cut-B 2-| rev

The result is as follows:

  1. 9 + 0RUd4U3HmSdMlgD7j0sf/r09MZFDVBS28W + pO2WcA

8. You can even generate a password that can be entered with only the left hand.

  1. </Dev/urandom tr-dc '12345! @ # $ % Qwertqwertasdfgasdfgzxcvbzxcvb' | head-c32; echo

The result is as follows:

  1. VTG3 # TR4sAgXg3Z % # WZG4ZQ @ GZ $ wdqF

9. If you use the above method every time, it is better to save it as a function. If this is done, you can use randpw to generate a random password at any time after the command is run for the first time. Maybe youYou can save it to your ~ /. Bashrc File

  1. Randpw () {</dev/urandom tr-dc _ A-Z-a-z-0-9 | head-c $ {1:-16}; echo ;}

The result is as follows:

  1. VgBX8cNo950RiykZRpPYa4BvbAvZbY_x

10. The last method to generate a random password is the simplest.It can also run under Windows with Cygwin installed. It can also be run in Mac OS X. I am sure someone will complain that the password generated in this method is not random by other methods. But in fact, if you use all the strings it generates as the password, the password is random enough.

  1. Date | md5sum

The result is as follows:

  1. E0d057b46a9a78450cbd94b25e574e79-
 
  1. Date | base64
The result is as follows:
  1. MjAxNOW5tCAwN + aciCAzMeaXpSDmmJ/mnJ/lm5sgMTc6MDA6MzYgQ1NUCg =
  1. Ifconfig | md5sum

The result is as follows:

  1. 7c4243742aa515d45c12deca31428a95-

 

You can even generate a nuclear bomb launch password. The following is an example of a growth password;

  1. Ifconfig | base64

The result is as follows:

  1. Bytes
  2. Bytes
  3. Bytes
  4. Bytes
  5. Bytes
  6. Bytes
  7. Bytes
  8. Bytes
  9. Bytes
  10. Bytes
  11. Bytes
  12. Bytes
  13. Bytes
  14. Bytes
  15. Bytes
  16. Bytes
  17. AUIpCgo =

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.