简体   繁体   中英

Compare password encrypted with apache2 MD5, htpasswd

I tried to compare two passwords with the Crypt algorithm:

  • The first one is generated by my program with PHP (md5())
  • The second password is created with Apache 2(with option - m).

    But I have a problem: when I compare the two passwords, with my code I obtain every time the same password (crypted). I noticed that for the same password if I repeat the process Apache 2 generates another encrypted password.

    Example :

    user = "user" password="password" ,

    apache2 generates this line:

    " user:$apr1$.1.Yc13v$uKn/tf7xbfDlo5qVpMoO/. " with MD5 algorythm.

    And in my program my password is encrypted as "5f4dcc3b5aa765d61d8327deb882cf99". And if I try to generate the same user and password with Apache 2 I have this line:

    "user:$apr1$yppuymMI$wucIxLfRKyWyZitz690Td1 "

    What should I do for comparisons for MD5?

    Thank you

  • Regardless of which hashing algorithm you use, I suspect your original problem was with different salt values --

    yppuymMI
    
    .1.Yc13v
    

    (Source: here )

    The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM