We can use the MKPASSWD command: This command is used to generate the password in the crypt format:
When you enter a command, the program asks for a password and then generates a crypt format string.
If you use the Apache Web server, you can also use HTPASSWD:
It doesn't matter what the user name is called, we are concerned with the password. This command will output a User:password format string, just copy the password field to the OK.
If you have OpenSSL, you can use the OpenSSL command:
OpenSSL Passwd-crypt MyPassword
Replace the MyPassword in the above command with the cipher string you want to use.
There are other ways to enter commands directly into the command line, but the problem is that you can see the password in the PS command, and the password will be recorded in Shell history.
But there is a solution to this problem: using a script, or a language interpreter.
Like using Perl:
Perl-e "Print crypt (' Password ', ' sa ');"
Perl requires an encrypted salt, such as a random string used in the use of SA (salt), which can generate different cryptographic results with different salts.
Ruby also needs to encrypt the salt:
Ruby-e ' print ' Password. Crypt ("JU"); Print ("n");
PHP can also:
Php-r "Print" (Crypt (' Password ', ' JU '). " n ");"
It should be noted that if you do not use encrypted salts (such as the Ju in the above command), the output string will not be crypt encrypted, but MD5 in encrypted format. So, the encrypted salt is actually a necessary parameter.
Python needs to import the crypt library and use the encrypted salts:
Python-c ' Import crypt; Print Crypt.crypt ("password", "Fx") '
The encrypted salt here is FX.
The database can also generate crypt passwords. For example, with MySQL:
echo "Select Encrypt (' Password ');" | Mysql
In addition, the TRF in Tcl,ubuntu, and the LUA Lua-crypt Plug-ins can achieve the same goal.
Welcome to add other ways!