* 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 { color: #3b5998; }
public function testEncryptData() { $enc = \IcyApril\CryptoLib::encryptData("test data", "test key"); $this->assertNotEquals("test data", $enc); $dec = \IcyApril\CryptoLib::decryptData($enc, "test key"); $this->assertEquals("test data", $dec); $this->setExpectedException(\Exception::class); \IcyApril\CryptoLib::encryptData("", "test key"); }