Need PHP Code for SHA1 function.

Hi,
I'm stuck with a verstion of PHP that doesn't support SHA1(). And I mistakenly developed a whole site with it. I found code for a SHA1 function but in Javascript at:
http://pajhome.org.uk/crypt/md5/sha1src.html
But has anyone seen code that I could use? Please help.
LVL 1
kalmenAsked:
Who is Participating?
 
hernst42Commented:
For a pure PHP-implementation (no extension needed) see (LGPL):

http://www.phpclasses.org/browse/file/200.html
0
 
ZylochCommented:
Hi kalmen,

Take a look at the comments:
http://us4.php.net/sha1

Regards,
Zyloch
0
 
kalmenAuthor Commented:
I found the class, so I guess my equivalent function would be:

function sha1($inputString) {

  $sha = new SHA;
  $hasharray = $sha->hash_string($inputString);
  return ($sha->hash_to_string( $hasharray ));

}
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
hernst42Commented:
yes

make an if condition around your, if the function already exists, you can use the one defined by php

if (!function_exits('sha1')) {

function sha1($inputString) {

  $sha = new SHA;
  $hasharray = $sha->hash_string($inputString);
  return ($sha->hash_to_string( $hasharray ));

}

}
0
 
kalmenAuthor Commented:
Let me test it tonight and hopefully get back to you tomorrow with my results.

Thanks
0
 
kalmenAuthor Commented:
It worked, Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.