surabaya web designer
cheap web promotion indonesia
design graphics and online shopping cart
     category      articles    
 

Adsense

Adwords

Article

Blog

CMS

CSS Style

Datacenter

Design Graphics

Flash Animation

Internet Radio

Messenger

Programming

Provider

Search Engine

Security

Security Web

SEF

SEO

Software

Software Web

Howto create a password for a htpasswd file using PHP

A user emailed me and asked how to create a password for a .htpasswd file using PHP. It is actually very simple.
Below is a PHP script that generates a password for .htpasswd from the clear text password stored in $clearTextPassword.

Please note: For Apache servers running on Windows you have to use the htpasswd program to generate password.

// Password to be encrypted for a .htpasswd file
$clearTextPassword = some-password;

// Encrypt password
$password = crypt($clearTextPassword, base64_encode($clearTextPassword));

// Print encrypted password
echo $password;
?>


Howto use the code:
[list=1]
[*]Copy the above the code and paste it into your favorite text editor (ie notepad).
[*]Change some-password to the password you want to encrypt.
[*]Save the code in file called htpasswd.php.
[*]Upload htpasswd.php to your webserver.
[*]Execute the code by going to http://www.your-domain.com/htpasswd.php
[*]The outputted text is your encrypted password.
[/list:o]

You can ofcourse also use the htpasswd-generator if you dont want your own script.

OTHER ARTICLES

Prevent htaccess From Hack 3

Top 7 PHP Security Blunders (1)

Register Global

Safeguard your XML based messages 4

Safeguard your XML based messages 2

Safeguard your XML based messages

Preventing directory listing

Prevent htaccess From Hack 1

Protecting your bandwidth

About Super Global