Re: Encrypting Passwords
| From: | Rasmus Lerdorf | Date: | Tue, 02 Jan 2001 22:58:45 +0000 |
| Subject: | Re: Encrypting Passwords | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32373@lists.php.net to get a copy of this message | ||
Use the crypt() function with a SALT that starts with $1$ and it should
give you the right thing.
-Rasmus
On Sat, 30 Dec 2000 o.cook@etoncollege.org.uk wrote:
> An example line of my /etc/shadow is
>
> oltest:$1$scWuGnwQ$u11q3QKMB8m4H00U3WJvY1:11318:0:99999:7:::
>
> The password part of that line being "$1$scWuGnwQ$u11q3QKMB8m4H00U3WJvY1"
>
> I need to work out how to generate such encrypted passwords from within PHP
> itself, for the following reason:
>
> - I'm writing a PHP shell script that will be run by an admin and will add
> users and simultaneously add their details to a database
> - I will be using the 'useradd' unix command which takes a "-p" option.
> However, the password supplied to -p must be *pre-encrypted*
>
> The man page for useradd mentions using the crypt C function, but I can't
> see how to do that in relation to PHP.
>
> >From the PHP function manual on crypt "CRYPT_MD5 - MD5 encryption with a
> 12-char SALT starting with $1$ " seems to be what I should be looking at,
> but after a bit of trouble I still can't get what I want. For starters, how
> do I know what to use for salt. What does the unix passwd command use for
> salt?
>
> I hope someone will be able to help me some!
>
> Thanks very much,
>
> Ollie
>
> ---
> Do radioactive cats have 18 half-lives?
>
> http://pgpkeys.mit.edu:11371/pks/lookup?op=get&search=0x53D29567
> ---
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>