Example #1
0
 */
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;
            }
Example #2
0
 public function testGenerateSalt()
 {
     $saltA = \IcyApril\CryptoLib::generateSalt();
     $this->assertEquals(127, strlen($saltA));
     $saltB = \IcyApril\CryptoLib::generateSalt();
     $this->assertEquals(127, strlen($saltB));
     $this->assertNotEquals($saltA, $saltB);
 }