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:
- Date + % s | sha256sum | base64 | head-c 32; echo
The result is as follows:
- 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:
- </Dev/urandom tr-dc _ A-Z-a-z-0-9 | head-c $ {1:-32}; echo
The result is as follows:
- PDj0Xwz7exD_Qb5B27BwWsM1hrF3a7cJ
3. Use Random Functions of openssl
- Openssl rand-base64 32
The result is as follows:
- RYJWqJlTLAYeX3j7nCbir20h1k/0 CnqLNEuNyTScfKo =
4. This method is similar to the previous urandom.But it works reversely.
- Tr-cd '[: alnum:]' </dev/urandom | fold-w32 | head-n1; echo
The result is as follows:
- TpgudzF7sqtU4yyW2LVhmUQOZIQi87
5. Use the string commandWhich outputs printable strings from a file
- Strings/dev/urandom | grep-o '[[: alnum:]' | head-n 32 | tr-d '\ n'; echo
The result is as follows:
- W4v1iqtkmq8sidd9jxdqnpg8hp1_8
6. This is a simpler version of urandom.
- </Dev/urandom tr-dc _ A-Z-a-z-0-9 | head-c32; echo
The result is as follows:
- RMDlGSPN_bm-IZVFWz9BEi0rF-jIy6gs
7. Use a very useful dd command
- Dd if =/dev/urandom bs = 1 count = 32 2>/dev/null | base64-w 0 | rev | cut-B 2-| rev
The result is as follows:
- 9 + 0RUd4U3HmSdMlgD7j0sf/r09MZFDVBS28W + pO2WcA
8. You can even generate a password that can be entered with only the left hand.
- </Dev/urandom tr-dc '12345! @ # $ % Qwertqwertasdfgasdfgzxcvbzxcvb' | head-c32; echo
The result is as follows:
- 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
- Randpw () {</dev/urandom tr-dc _ A-Z-a-z-0-9 | head-c $ {1:-16}; echo ;}
The result is as follows:
- 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.
- Date | md5sum
The result is as follows:
- E0d057b46a9a78450cbd94b25e574e79-
- Date | base64
The result is as follows:
- MjAxNOW5tCAwN + aciCAzMeaXpSDmmJ/mnJ/lm5sgMTc6MDA6MzYgQ1NUCg =
- Ifconfig | md5sum
The result is as follows:
- 7c4243742aa515d45c12deca31428a95-
You can even generate a nuclear bomb launch password. The following is an example of a growth password;
- Ifconfig | base64
The result is as follows:
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- Bytes
- AUIpCgo =