PMA\libraries\plugins\auth\AuthenticationCookie::getMACSecret PHP Method

getMACSecret() public method

Derives MAC secret from encryption secret.
public getMACSecret ( string $secret ) : string
$secret string the secret
return string the MAC secret
    public function getMACSecret($secret)
    {
        // Grab first part, up to 16 chars
        // The MAC and AES secrets can overlap if original secret is short
        $length = strlen($secret);
        if ($length > 16) {
            return substr($secret, 0, 16);
        }
        return $this->enlargeSecret($length == 1 ? $secret : substr($secret, 0, -1));
    }

Usage Example

 /**
  * Test for secret splitting using getAESSecret
  *
  * @return void
  *
  * @dataProvider secretsProvider
  */
 public function testMACSecretSplit($secret, $mac, $aes)
 {
     $this->assertEquals($mac, $this->object->getMACSecret($secret));
 }