Solved

Need PHP Code for SHA1 function.

Posted on 2004-09-27
6
215 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Expert Comment

by:hernst42
Comment Utility
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
Comment Utility
Let me test it tonight and hopefully get back to you tomorrow with my results.

Thanks
0
 
LVL 1

Author Comment

by:kalmen
Comment Utility
It worked, Thanks.
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now