.HTPASSWD : Need Help in generating it through PHP

Discussion in 'Apache' started by bonjo, Oct 18, 2006.

  1. #1
    When I generate the password using the htpasswd tool it generates the password in MD5 APR format.

    Please let me know how I can generate the same using php.

    Hope I will get your help in this
     
    bonjo, Oct 18, 2006 IP
  2. owned

    owned Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Google -> "htpasswd php", first hit.

    E.g.
    function sha($pass){
      return "{SHA}" . base64_encode(pack("H*", sha1($pass)));
    }
    Code (markup):
     
    owned, Oct 18, 2006 IP
  3. Smaaz

    Smaaz Notable Member

    Messages:
    2,425
    Likes Received:
    160
    Best Answers:
    0
    Trophy Points:
    250
    #3
    Or for MD5 -> http://de2.php.net/manual/de/function.md5.php
     
    Smaaz, Oct 18, 2006 IP
  4. bonjo

    bonjo Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    awesome!! it works with SHA... i have been meddling with MD5 stuff.... so far...

    thx man!!
     
    bonjo, Oct 19, 2006 IP
  5. owned

    owned Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ya htpasswd seems to work with 'almost anything'.

    Eg. This maybe works too:
    function htpasswd($pass){
      return crypt($pass);
    }
    Code (markup):
    ((Pws can be stored like "user:yourpass" without hash too.))
     
    owned, Oct 19, 2006 IP