Results 1 to 6 of 6

Thread: How do I encrypt (and decrypt) htpasswd files?

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    3

    Default How do I encrypt (and decrypt) htpasswd files?

    I have written an entire register/login script for my site in php. I just recently switched hosts to a company called DailyRazor.com. They have Cpanel 10.

    I am trying to password protect a directory, but I want the users to have to register on my site before they can access it. I would like to use CPanel's built in directory protection, but I am having a problem regarding the passwords.

    I know how I can write the information to the htpasswd file, but I don't know how to encrypt the passwords when I write them to the file.

    I guess what i'm asking for is what type of encryption is used on passwords when the htpasswd files are written. A code example as well as an explanation would be great, because I do not know exactly what "salt" is, except that it pertains to encryption.

    Any help would be greatly appreciated.

  2. #2
    Registered Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    1,052

    Default

    Use the below url to encrypt the password :-
    http://www.desilva.biz/apache/pwdweb.html

    You will just have to provide the username/password. It will encrypt the password and will provide you. Just copy/ paste the Username/Password in .htpasswd file and you will be able to access the directory with that particular Username.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    3

    Default

    I need the code that the password encryption generator on the link you gave me is using. Where can I find it?

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    3

    Default

    I was able to find the code online. Here it is:

    Code:
    $password = crypt($clearTextPassword, base64_encode($clearTextPassword));

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    1

    Default

    Quote Originally Posted by agreenbhm View Post
    I was able to find the code online. Here it is:

    Code:
    $password = crypt($clearTextPassword, base64_encode($clearTextPassword));
    Im looking for the encryption method to. This one doesn't seem right though, because it generates the same password on refresh, while the given site doesn't.

    Greets Bas

  6. #6
    Registered Member This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,499

    Default

    That just means it uses a different salt. You need to look into how the crypt() function works. Bear in mind that it is one-way encryption only, i.e. you cannot decrypt it (you'd have to use a brute-force password guesser to do that).
    Jonathan Michaelson

    cPanel Server Configuration, Security and Antivirus/AntiSpam Services
    http://www.configserver.com

Similar Threads

  1. Suspicious activities on SSH. How do we decrypt these characters?
    By Roy@ENHOST in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 03-01-2009, 01:16 AM
  2. CP11 - .htpasswd files RELOCATED!
    By soundguy in forum cPanel & WHM Discussions
    Replies: 13
    Last Post: 06-12-2007, 04:41 PM
  3. Looking For Decrypt Function Please
    By HappyPappy in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 05-15-2007, 02:20 PM
  4. Encrypt
    By DevinC in forum cPanel & WHM Discussions
    Replies: 4
    Last Post: 07-14-2006, 01:43 PM
  5. encrypted SSL- Private key - decrypt how ?
    By jeroman8 in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 03-26-2006, 12:25 PM
bargain