public function testRandomString() { $rand = \IcyApril\CryptoLib::randomString(5); $this->assertEquals(5, strlen($rand)); $rand = \IcyApril\CryptoLib::randomString(1); $this->assertEquals(1, strlen($rand)); $this->setExpectedException(Exception::class); \IcyApril\CryptoLib::randomString(0); $this->setExpectedException(Exception::class); \IcyApril\CryptoLib::randomString(-10); }
/** * Start off my requiring the library in our demo script. */ 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;