Home / APIs / _hash_hmac() – Internal compat function to mimic hash_hmac().

You appear to be a bot. Output may be restricted

Description

Internal compat function to mimic hash_hmac().

Usage

$string|false = _hash_hmac( $algo, $data, $key, $raw_output );

Parameters

$algo
( string ) required – Hash algorithm. Accepts 'md5' or 'sha1'.
$data
( string ) required – Data to be hashed.
$key
( string ) required – Secret key to use for generating the hash.
$raw_output
( bool ) optional – Optional. Whether to output raw binary data (true), or lowercase hexits (false). Default false.

Returns

string|false The hash in output determined by $raw_output`. False if `$algo is unknown or invalid.

Source

File name: wordpress/wp-includes/compat.php
Lines: 1 to 22 of 22

function _hash_hmac($algo, $data, $key, $raw_output = false) {
  $packs = array('md5' => 'H32', 'sha1' => 'H40');

  if ( !isset($packs[$algo]) )
    return false;

  $pack = $packs[$algo];

  if (strlen($key) > 64)
    $key = pack($pack, $algo($key));

  $key = str_pad($key, 64, chr(0));

  $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
  $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));

  $hmac = $algo($opad . pack($pack, $algo($ipad . $data)));

  if ( $raw_output )
    return pack( $pack, $hmac );
  return $hmac;
}
 

 View on GitHub View on Trac

Published: 12th March 2017 | Last updated: 12th March 2017

Information

Function name: _hash_hmac
Plugin ref: WordPress
Version: 5.0.3
Sourcefile: wp-includes/compat.php
File ref: wp-includes/compat.php
API type: private
Deprecated?: No
API Letters: _,H

  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Files
  • Hooks
  • Classes
  • Sites
  • Sitemap
  • Blog
WooCommerce a2z WooCommerce a2z
WooCommerce

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins