|
|
|
Tutorial pages:« 1 » |
|
wmikke
|
| Encryption - Posted on: 30-04-2005 at 11:34 | |

|
When you store important things in your database, like passwords. It's not safe to save them unencrypted.
There are in PHP different ways to encrypte your passwords. The most used function is md5();
but you can also use SHA1 and crc32.
The savest way is to use combined encryptions, but it's not necessary.
MD5
MD5 is available since PHP3. MD5 is the most used way of encrypting but not the savest, there is already a way to decrypt MD5.
MD5 generates a hexdecimal of 32 sign, which you can put in a database or whatever.
How do you use MD5? Here is a simple example.
1 2 3 4 5 6 7
|
|
<?
$password = "wmikke";
$hex = md5("$password");
echo "$hex;
?>
|
|
|
SHA1
SHA1 is available since PHP version 4.3.0
SHA1 generates, from a hash, a hexdecimal number of 40 numbers.
SHA1 is not used so much as MD5 but is safer though.
The use of SHA1 is exactly the same as MD5.
1 2 3 4 5 6
|
|
<?
$password = "wmikke";
$hex = sha1("$password");
echo "$hex";
?>
|
|
|
crc32
crc32 is available since PHP version 4.1.0
crc32 has a completely different use than md5 and sha1, it doesn't generate a hexdecimal but a polynomial of 32bit lenghts.
crc32 isn't used much. But i'll show you an example of the use of crc32.
1 2 3 4 5 6 7
|
|
<?
$password = "wmikke";
$hex = crc32("$password");
echo "$hex";
?>
|
|
|
When you have read this tutorial you have to be enable to save your important stuff on a safe way! Good luck!
Don't wait and sit around while you have a question, come to our forum!
|
|
|
|
|