Re: [Hampshire] [OT] Linux compatible crypt(3) password from…

Top Page

Reply to this message
Author: Damian Brasher
Date:  
To: hampshire
Subject: Re: [Hampshire] [OT] Linux compatible crypt(3) password from Perl

Simon wrote:
> Damian Brasher wrote:
>> I am writing subroutine to generate a Linux compatible password for the

command useradd executed from within a Perl script, where useradd can be
supplied a compatible encrytped password as with crypt(3) generated
passwords. I need something like this:
>>
> If your /etc/shadow has passwords like
>     $1$abdef$7Jtzy.MmT50duhCix.rlv0
> then it is using MD5 passwords rather than the DES ones which "crypt"

defaults to. For this, the salt in crypt must start "$1$" followed by up
to eight characters and an optional trailing "$" e.g.:
>     $fred=crypt "HelloMum","\$1\$abcdef";
>     print "$fred\n"
> On my eeePc, this returns the above password.

>


Thanks Simon, crypt worked after all, not sure what I did, perhaps some
variable buffers needed clearing, but cooking dinner generally doesn't fix
this kind of thing. I've made a note include the MD5 method in the subroutine
as an alternative.

autoflush springs to mind $|

Damian

--
WWW http://www.diaser.org.uk - working together to make long term digital
archives more accessible

RSS http://sourceforge.net/export/rss2_projfiles.php?group_id=258272



--
WWW http://www.diaser.org.uk - working together to make long term digital
archives more accessible

RSS http://sourceforge.net/export/rss2_projfiles.php?group_id=258272

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.