require_once '../src/CryptoLib.php'; /** * Some nice debugging messages. */ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); use IcyApril\CryptoLib; /** * Standard procedural testers. */ $randomInteger = CryptoLib::randomInt(0, 255); $randomHex = CryptoLib::randomHex(10); $randomString = CryptoLib::randomString(10); $repeatPercentage = CryptoLib::checkRandomNumberRepeatability(); $salt = CryptoLib::generateSalt(); $testHash = CryptoLib::hash("test"); $validateHash = CryptoLib::validateHash($testHash, "test"); $encryptedString = CryptoLib::encryptData("Test string.", "passwd"); $decryptedString = CryptoLib::decryptData($encryptedString, 'passwd'); ?> <html> <head> <title>CryptoLib Tester</title> <style> body { font-family: Helvetica, Arial, sans-serif; font-size: 16px; } a, a:link, a:hover, a:visited, a:active {
public function testValidateHash() { $hash = \IcyApril\CryptoLib::hash("test"); $valid = \IcyApril\CryptoLib::validateHash($hash, "test"); $this->assertTrue($valid); $this->setExpectedException(\Exception::class); $hash = \IcyApril\CryptoLib::hash("test"); \IcyApril\CryptoLib::validateHash("test", $hash); }