Tuesday, November 07, 2006

What is sha1 in PHP?

"The SHA (Secure Hash Algorithm) family is a set of related cryptographic hash functions. The most commonly used function in the family, SHA-1, is employed in a large variety of popular security applications and protocols, including TLS, SSL, PGP, SSH, S/MIME, and IPSec. SHA-1 is considered to be the successor to MD5, an earlier, widely-used hash function. The SHA algorithms were designed by the National Security Agency (NSA) and published as a US government standard."

How to make a basic SHA1 encryption?

This is the code

<?php
$var = 'I like cheese dude!!';
$var = sha1($var);
echo $var;
?>

Like MD5, we can compare two variables.
<?php
$var2 = '73f859db5ab9bc7c3733b0f1792d3e5a316e0f97';//I like cheese dude!!
$var = 'I like cheese dude!!';
$var = sha1($var);
if($var == $var2)
{
echo 'Variable 1 and Variable 2 Match';
}
else
{
echo 'Not mach';
}
?>

No comments: