Buy Cheap Software - Discount Software Create one way encryption with crypt () - Le Minh Duc
Create one way encryption with crypt ()
Thursday, 25 May 2006

In PHP we can use the crypt () function to create one way encryption. This means that the data is encrypted but cannot easily be decrypted. Although at first glance that may seem useless, it is actually very useful when working with passwords.

When a user chooses their password, the password is then encrypted and the encrypted version of this password is saved. The next time the user goes to login, their password is encrypted again and then checked against the already saved (encrypted) version to see if they are the same. This way if the data is intercepted, they only ever see the encrypted version.

The crypt function is phrased as: crypt ( input_string, salt)

In this case input_string is the string you would like to encrypt (your password for example,) and salt is an optional parameter that influences how the encryption will work

PHP by default uses a two character DES salt string. If your system standard is MD5, a 12-character salt string is used.

The following are the four types of salt that work with all crypt () functions.

CRYPT_STD_DES - Standard DES-based encryption with a two character salt
CRYPT_EXT_DES - Extended DES-based encryption with a nine character salt
CRYPT_MD5 - MD5 encryption with a twelve character salt starting with $1$
CRYPT_BLOWFISH - Blowfish encryption with a sixteen character salt starting with $2$ or $2a$




Be first to comment this article

Only registered users can write comments.
Please login or register.

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved

 
< Prev
Beautiful Scenery