Crypt function

P

petrucci

Hi everyone

i'm using crypt function to verify an input password with password
stored in /etc/shadow.

I'm on Red Hat 9 but crypt doesn't function, in other words it return a
different crypted password. Why?
 
G

Gunnar Hjalmarsson

petrucci said:
i'm using crypt function to verify an input password with password
stored in /etc/shadow.

I'm on Red Hat 9 but crypt doesn't function, in other words it return a
different crypted password. Why?

Since the crypt() function works just fine, it's most likely caused by
your code. How about posting a short but complete program that
demonstrates the problem?
 
P

Paul Lalli

petrucci said:
i'm using crypt function to verify an input password with password
stored in /etc/shadow.

I'm on Red Hat 9 but crypt doesn't function, in other words it return a
different crypted password. Why?

I'm going to make a completely random guess, as that's the only kind
that can be made when you showed absolutely no code of any kind.

You forgot to chomp() the password read from the keyboard or file, and
therefore you used crypt() on "password\n" instead of "password", which
led to a different crypted password than you found in /etc/shadow.

Now, if my completely random guess is incorrect, it would be helpful
for you to show a short-but-complete script which demonstrates your
problem.

Have you read the Posting Guidelines for this group?

Paul Lalli
 
P

petrucci

no problem.. it simple sound like this:

print crypt("mypwd","encryptedpwd")

but the output isn't like "mypwd" entry in shadow file
 
A

Arndt Jonasson

petrucci said:
i'm using crypt function to verify an input password with password
stored in /etc/shadow.

I'm on Red Hat 9 but crypt doesn't function, in other words it return a
different crypted password. Why?

Some versions of Linux (maybe all?) offer a stronger alternative to
the traditional Unix encryption for passwords. Maybe that alternative
is in effect on your computer? I don't remember the name of it or in
what manual pages to look, unfortunately.
 
D

Darren Dunham

petrucci said:
no problem.. it simple sound like this:
print crypt("mypwd","encryptedpwd")
but the output isn't like "mypwd" entry in shadow file

The shadow file may use other algorithms than crypt(3). If the encoded
password isn't exactly 13 characters long, then it's not crypt, but
something else (possibly some form of MD5 checksum).
 
G

Gunnar Hjalmarsson

[ Please read and follow the posting guidelines for this group:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
which includes providing some context when replying. ]
no problem.. it simple sound like this:

print crypt("mypwd","encryptedpwd")

That's not a complete program, and it obviously doesn't provide any
additional information that would help us help you.
but the output isn't like "mypwd" entry in shadow file

Of course not. Did you even read the docs for the crypt() function?

perldoc -f crypt
 
J

Josef Moellers

Darren said:
The shadow file may use other algorithms than crypt(3). If the encoded
password isn't exactly 13 characters long, then it's not crypt, but
something else (possibly some form of MD5 checksum).

IIRC MD5-Passwords can be recognized by a leading '$1$'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top