Phalcon\Test\Proxy\Security::computeHmac PHP Method

computeHmac() public method

public computeHmac ( string $data, string $key, string $algo, boolean $raw = false ) : string
$data string
$key string
$algo string
$raw boolean
return string
    public function computeHmac($data, $key, $algo, $raw = false)
    {
        return parent::computeHmac($data, $key, $algo, $raw);
    }

Usage Example

Example #1
0
 /**
  * Tests the HMAC computation
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-12
  */
 public function testSecurityComputeHMAC()
 {
     $this->specify('The HMAC computation values are not identical', function ($key) {
         $security = new Security();
         $data = [];
         for ($i = 1; $i < 256; ++$i) {
             $data[] = str_repeat('a', $i);
         }
         foreach ($data as $text) {
             expect($security->computeHmac($text, $key, 'md5'))->equals(hash_hmac('md5', $text, $key));
         }
     }, ['examples' => [[substr(md5('test', true), 0, strlen(md5('test', true)) / 2)], [md5('test', true)], [md5('test', true) . md5('test', true)]]]);
 }