faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 14 people (71%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I calculate sha1 in raw binary format without php5?

Mar 19th, 2008 22:08
ha mo, Shashank Tripathi,


The SHA1 function returns a 40 character hash of the string supplied 
to it. PHP5 also offers an optional second parameter to return the 
hash in 20 character raw binary format. 
If you want to return the raw binary format in versions of PHP prior to 
5.0.0, one kludgish solution that works well is: 
<?
$raw = pack("H*", sha1($str));
?>
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com