WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : what salt do I have to feed the crypt function with to make it work like the htpasswd command of apache?
Categories : Algorithms, PHP, Authentication Update Picture
Anton Stockl
Date : Oct 23rd 1998
Grade : 2 of 5 (graded 3 times)
Viewed : 9350
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Anton Stockl
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

you use one that you make up. maybe like this:


$salt = substr(0, 2, md5(Date());
$encrypted = crypt($string, $salt);


The salt merely ensures that if 2 people have the same password, their
"crypted" representations are not the same (unless they use the same
salt). When you want to compare a password, you first find the already
encrypted one, grab the salt (the first 2 chars), and then encrypt the
password and compare it.



PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character.
Categories : PHP, Algorithms, Security, Authentication, Encryption
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
Function to remember password
Categories : PHP, Authentication, Personalization and Membership
Boolean Keyword Interpreter
Categories : PHP, Algorithms, Search Engines
Prime number finder (Sieve of Erastothenes)
Categories : PHP, Algorithms, Math.
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
Using Postgres and PHP3 Authentication from a Web application
Categories : PostgreSQL, HTML and PHP, Authentication, PHP
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
Validation function for LUHNMod10 and variant. Can discriminate credit card numbers of varying lengths. Uses [Double >> Sum-of-Digits] transform.
Categories : Credit Cards, Authentication, Ecommerce, PHP
The Porter Word Stemming Algorithm in PHP Reduces words to their base stem for search engines and indexing
Categories : Algorithms, PHP, Strings
Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users).
Categories : Algorithms, Email, PHP
A recursive function to traverse a multi-dimensional array where the dimensions are not known
Categories : Arrays, PHP, Algorithms
Full membership authentication system.
Categories : Authentication, MySQL, PHP, Databases
Kasskooye($path) tell you the complete size of a folder
Categories : PHP, Algorithms, Utilities, Filesystem
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
 Teeranai Thamshutiporn wrote : 199
I try to use your salt but It said :
Warning: Wrong parameter count for date() 
in /home/internet/public_html/admin/passwd.php3 

What`s wrong ?

I wanna To Check and Change Password on Linux vai PHP3 
code [My Server use MD5]. Do you have same code ?

Regards,
Teeranai Thamshutiporn
 
 Matt Szubrycht wrote :392
Hi,

You need to provide the format of the date ... 
I would use the number of seconds since the epoch, 
therefore, it should looks somewhat like this:

$salt = substr(0, 2, md5(Date("U"))); 
    $encrypted = crypt($string, $salt);

That should do the trick, at least it works on my Cobalt 
RAQ3 running Linux.

Regards,
Matt