PHP / MySQL

  1. Home
  2. Computing & Technology
  3. PHP / MySQL

Crypt () PHP Function

By Angela Bradley, About.com

Definition: They Crypt () Function is used for data encryption using an one way algorithm. It is phrased as: string crypt (string input_string , string salt)

Input_string is the string you would like to encrypt, and salt is an optional parameter that influences how the encryption will work. By default PHP uses a two character DES salt string, however if your system standard is MD5, a 12-character salt string is used.

This is most frequently used for handling passwords from the browser to the server.

Also Known As: encrypt, encryption
Examples: Without salt:

<?php
$encrypt = crypt('TextToEncrypt');
print $encrypt . “ is the encrypted version of TextToEncrypt”;
?>

With Salt:

<?php
$encrypt = crypt('TextToEncrypt' , 'd4');
print $encrypt . " is the CRYPT_STD_DES version of TextToEncrypt";
?>

For more information please read this article on using the crypt () function.

Explore PHP / MySQL

More from About.com

PHP / MySQL

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Crypt PHP - data encryption - file encryption

©2008 About.com, a part of The New York Times Company.

All rights reserved.