SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Can PHP encode passwords the way that a .htaccess file needs to restrict access?

    If so is it: md5()?

    Thanks

    -Peter

  2. #2
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes PHP can encode passwords for htpasswd type files.
    And yes i am 99% sure it is md5....i know i have done this before just cant remember.
    Try md5, it will almost certainly work
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually crypt() is what you need

    function random() {
    srand ((double) microtime() * 1000000);
    return rand();
    }

    function crypt_password($password) {
    $salt = random();
    $salt = substr($salt, 0, 2);
    return crypt($password, $salt);
    }


    Here is two functions I use for creating htpasswd passwords
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    From a thread at another forum:

    "....linux/unix uses CRYPT to generate the passwords - on Windows we are restricted to MD5"

  5. #5
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That would explain it...i have this little app somewhere that i use to generate htpasswd files and im sure that uses md5. Having said that i only ever run it on my windows box..
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •