Beispiel #1
0
 public function testRandomHex()
 {
     $rand = \IcyApril\CryptoLib::randomHex();
     $this->assertEquals(128, strlen($rand));
     $rand = \IcyApril\CryptoLib::randomHex(256);
     $this->assertEquals(256, strlen($rand));
     $rand = \IcyApril\CryptoLib::randomHex(128);
     $this->assertEquals(128, strlen($rand));
     $rand = \IcyApril\CryptoLib::randomHex(64);
     $this->assertEquals(64, strlen($rand));
     $rand = \IcyApril\CryptoLib::randomHex(2);
     $this->assertEquals(2, strlen($rand));
     $rand = \IcyApril\CryptoLib::randomHex(2);
     $this->assertEquals(2, strlen($rand));
     $this->setExpectedException(Exception::class);
     \IcyApril\CryptoLib::randomHex(0);
 }
Beispiel #2
0
*/
/**
 * 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;