Advertisement
Guest User

Untitled

a guest
May 28th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function sha1_hmac($key,$data,$blockSize=64,$opad=0x5c,$ipad=0x36) {
  2.  
  3. // Keys longer than blocksize are shortened
  4. if (strlen($key) > $blockSize) {
  5. $key = sha1($key,true);
  6. }
  7.  
  8. // Keys shorter than blocksize are right, zero-padded (concatenated)
  9. $key = str_pad($key,$blockSize,chr(0x00),STR_PAD_RIGHT);
  10. $o_key_pad = $i_key_pad = '';
  11.  
  12. for($i = 0;$i < $blockSize;$i++) {
  13. $o_key_pad .= chr(ord(substr($key,$i,1)) ^ $opad);
  14. $i_key_pad .= chr(ord(substr($key,$i,1)) ^ $ipad);
  15. }
  16.  
  17. return sha1($o_key_pad.sha1($i_key_pad.$data,true),true);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement