/** * {@inheritDoc} * @see Doctrine\DBAL\Types\Type::convertToPHPValue() */ public function convertToPHPValue($value, AbstractPlatform $platform) { return $value == null ? null : SecureHash::fromBase64($value); }
/** * {@inheritDoc} * @see Doctrine\ODM\MongoDB\Types\Type::convertToPHPValue() */ public function convertToPHPValue($value) { return $value == null ? null : SecureHash::fromBase64($value); }
/** * Returns true of this secure hash may have been derived from the given clear data. * @param string $data The clear data bytes. May not be null. * @param SecureHash $secureHash The secure hash object we are checking to * see if there is a match. * @return True if this hash may have been derived from the clear data. False, otherwise. */ public function check($data, $secureHash) { $candidateHashValue = $this->computeHash($data, $secureHash->getRandomSalt()); return $secureHash->getHashValue() === $candidateHashValue; }
/** * @param serialized */ public function unserialize($serialized) { $secureHash = SecureHash::fromBase64($serialized, 'US-ASCII'); $this->hashValue = $secureHash->getHashValue(); $this->randomSalt = $secureHash->getRandomSalt(); }
public function testFromBase64() { $secureHash = SecureHash::fromBase64(SecureHashTest::EXPECTED_BASE64_VALUE, 'US-ASCII'); $this->assertEquals(SecureHashTest::EXPECTED_HASH_VALUE, $secureHash->getHashValue()); $this->assertEquals(SecureHashTest::EXPECTED_SALT_VALUE, $secureHash->getRandomSalt()); }