Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 May 1999 13:34:22 -0700 (PDT)
From:      Doug White <dwhite@resnet.uoregon.edu>
To:        Korvus <korvus@tasam.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: how to use crypt()...
Message-ID:  <Pine.BSF.4.03.9905121333100.23756-100000@resnet.uoregon.edu>
In-Reply-To: <008201be9a52$764ce820$948cfea9@korvus>

next in thread | previous in thread | raw e-mail | index | archive | help

On Sun, 9 May 1999, Korvus wrote:

> I'm looking to make a quick C program (genpass.c) that can be used in
> scripts like the following (this is only a quick example, it may not be 100%
> correct):
> 
>   #!/bin/sh
>   # $1 is a username, $2 is a new password for that user
>   export hashedpass = `echo $2 | genpass`
>   chpass -p "$hashedpass" $1
> 
> My only problem in doing this is my incomplete understanding of crypt().
> >From reading the help files, it appears as if a random 4-byte salt and a
> 4-byte "iteration count" are used as the second parameter.  I have no clue
> what the "iteration count" should be.  I looked at the
> /usr/src/usr.bin/passwd sources, but I still couldn't fully understand this.
> If someone could write a quick C program to do this, I would be very
> thankful (especially if they could also explain the process).  Thanks...

He're the rule:

.  If you're changing an existing password, provide the old encrypted
password as the salt.

.  Otherwise, if you are creating a password for the first time, use
random data.

Doug White                               
Internet:  dwhite@resnet.uoregon.edu    | FreeBSD: The Power to Serve
http://gladstone.uoregon.edu/~dwhite    | www.freebsd.org



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?Pine.BSF.4.03.9905121333100.23756-100000>