Can someone tell me in really slow terms the difference between these 2 lines of PHP?
$hassh = base64_encode(sha1($word));
$hassh = hash(’sha1′, $word);
Can someone tell me in really slow terms the difference between these 2 lines of PHP?
$hassh = base64_encode(sha1($word));
$hassh = hash(’sha1′, $word);
Not sure what you mean by "different", but the first line :
$hassh = base64_encode(sha1($word));
var_dump($hassh);
gets you :
string 'YWFmNGM2MWRkY2M1ZThhMmRhYmVkZTBmM2I0ODJjZDlhZWE5NDM0ZA==' (length=56)
Where the second :
$hassh = hash('sha1', $word);
var_dump($hassh);
Gets you :
string 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d' (length=40)
So, first of all, I am not sure you meant to use base64_encode : doesn't seem to be really usefull here, and probably isn't necessary : sha1 already returns a string :
$word = 'hello';
var_dump(sha1($word));
Gets you :
string 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d' (length=40)
Excepts for this, those two lines, with the sha1 algorithm, get the same thing. Difference probably is that hash
can work with a lot of hashing algorithms.
Oh, and, also :