Solved

Need PHP Code for SHA1 function.

Posted on 2004-09-27
6
253 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:kalmen
  • 3
  • 2
6 Comments
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 20 total points
ID: 12158471
Hi kalmen,

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

Regards,
Zyloch
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 480 total points
ID: 12158620
For a pure PHP-implementation (no extension needed) see (LGPL):

http://www.phpclasses.org/browse/file/200.html
0
 
LVL 1

Author Comment

by:kalmen
ID: 12168152
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 48

Expert Comment

by:hernst42
ID: 12168496
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
 
LVL 1

Author Comment

by:kalmen
ID: 12168688
Let me test it tonight and hopefully get back to you tomorrow with my results.

Thanks
0
 
LVL 1

Author Comment

by:kalmen
ID: 12172761
It worked, Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question