validateData() public method

Validates if data is tampered.
public validateData ( $data ) : string
return string the real data with HMAC stripped off. False if the data is tampered.
Exemplo n.º 1
0
 public function testValidateData()
 {
     $sec = new TSecurityManager();
     $sec->init(null);
     $sec->setValidationKey('aKey');
     $sec->setValidation('SHA1');
     $hashed = $sec->hashData('A text to hash');
     self::assertEquals('A text to hash', $sec->validateData($hashed));
     // try to alter the hashed data
     $hashed[45] = "z";
     self::assertFalse($sec->validateData($hashed));
     // and a test without tampered data
     self::assertFalse($sec->validateData('bad'));
 }