Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jun 1998 22:20:50 +0800 (SGT)
From:      chas <panda@peace.com.my>
To:        Dean Hollister <dean@odyssey.apana.org.au>, FreeBSD Qestions <freebsd-questions@FreeBSD.ORG>
Cc:        mjm@attila.apana.org.au
Subject:   Re: Password crypt
Message-ID:  <3.0.32.19980616224243.00a28210@peace.com.my>

next in thread | raw e-mail | index | archive | help
The following function works in Python (bear with me) :

from crypt import *
def encryptpasswd(passwd):
	salt = str(random.random())[2:4]
	cryptpasswd = crypt(passwd, salt)
	return cryptpasswd

This function takes a string 'passwd' and 
returns the encrypted password after a unix 'crypt'.
You don't need to understand Python to see that
I just use a 2 character string as the salt. 

The returned string 'cryptpasswd' is then put into the
master.passwd record; I then call pwd_mkdb and the 
passwd works. Screwy, i know, but it works - since this
is a one-way hash as opposed to encryption/decryption.

So, bottomline : try using a random 2 character string.

chas


>We are developing an .html facility for members to change 
>their password on-line. But, I've hit a snag:
>
>I've assigned the new password to:
>
><in perl>
>
>$newpasswd
>
>But now need to encrypt it. I know the function to do this is:
>
>crypt($newpasswd,encryption key)
>
>But I don't know what the encryption key should be. Can anyone help?
>
>Regards,
>
>d.
>
>+--------------------------------------------------------+
>| Dean Hollister,           | dean@odyssey.apana.org.au* |
>| Region Co-Ordinator,      | 12840184 ICQ               |
>| APANA,                    |                            |
>| Western Australia.        | *finger A/C for DISCLAIMER | 
>+--------------------------------------------------------+
>ST:VOY Kess: "I wish people would stop talking to me as if
>              I'm still a child! I'm three years old now!"
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message
>
>

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.32.19980616224243.00a28210>