Re: how to create MD5 passwords
Michael Wood <mwood@its.uct.ac.za> writes:
> On Thu, Jan 24, 2002 at 08:56:56AM +0100, Rainer Sigl wrote:
> > Hi everyone,
> > please can me tell somebody how to make MD5 passwords in order
> > to supply it to ftppasswd file?
>
> You just need to call the standard crypt() function with the
> apropriate arguments. You can use perl or python or C or
> whatever to do it. e.g.:
Also, in this particular python example, make sure the LC_CTYPE locale
is set to 'C', or you might get weird characters in string.lowercase
and string.uppercase... ;-)
> $ python
Make that:
$ LC_CTYPE=C python
> Python 2.1.1 (#1, Nov 11 2001, 18:19:24)
> [GCC 2.95.4 20011006 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import string
> >>> import random
> >>> import crypt
> >>> saltchars = string.uppercase + string.lowercase + string.digits + "./"
> >>> s = []
> >>> for i in range(8):
> ... s.append(random.choice(saltchars))
> ...
> >>> salt = "$1$" + string.join(s, "")
> >>> passwd = "Password"
> >>> print crypt.crypt(passwd, salt)
> $1$e6TSyRDd$OcJO4kuY0I/mLED6n.tNi1
Phil.
Reply to: