Crypt function

Discussion in 'Perl Misc' started by petrucci, Sep 20, 2005.

  1. petrucci

    petrucci Guest

    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?
     
    petrucci, Sep 20, 2005
    #1
    1. Advertising

  2. petrucci wrote:
    > 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?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Sep 20, 2005
    #2
    1. Advertising

  3. petrucci

    Paul Lalli Guest

    petrucci wrote:
    > 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
     
    Paul Lalli, Sep 20, 2005
    #3
  4. petrucci

    petrucci Guest

    no problem.. it simple sound like this:

    print crypt("mypwd","encryptedpwd")

    but the output isn't like "mypwd" entry in shadow file
     
    petrucci, Sep 20, 2005
    #4
  5. "petrucci" <> writes:
    > 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.
     
    Arndt Jonasson, Sep 20, 2005
    #5
  6. petrucci <> wrote:
    > 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).

    --
    Darren Dunham
    Senior Technical Consultant TAOS http://www.taos.com/
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >
     
    Darren Dunham, Sep 20, 2005
    #6
  7. [ 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. ]

    petrucci wrote:
    > Gunnar Hjalmarsson wrote:
    >> petrucci wrote:
    >>> 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?

    >
    > 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

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Sep 20, 2005
    #7
  8. Darren Dunham wrote:
    > petrucci <> wrote:
    >
    >>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).
    >


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

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Moellers, Sep 21, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AdrianK
    Replies:
    0
    Views:
    1,564
    AdrianK
    Jul 9, 2003
  2. Marco Herrn

    more secure crypt() function

    Marco Herrn, Oct 4, 2003, in forum: Python
    Replies:
    3
    Views:
    377
    Marco Herrn
    Oct 4, 2003
  3. luca72

    python glibc crypt() function

    luca72, Apr 20, 2010, in forum: Python
    Replies:
    9
    Views:
    1,365
    geremy condra
    Apr 21, 2010
  4. Cosmia Luna
    Replies:
    4
    Views:
    341
    Cosmia Luna
    Mar 11, 2012
  5. asg

    de-crypt... crypt

    asg, Dec 23, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    141
Loading...

Share This Page