PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Michael Cummings   Encryption Helper   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Encryption Helper
Encrypt and decrypt of GET query lists
Author: By
Last change:
Date: 7 years ago
Size: 1,000 bytes
 

Contents

Class file image Download
<?php
declare(strict_types = 1);
/**
 * Created by PhpStorm.
 * User: Dragonaire
 * Date: 10/24/2016
 * Time: 3:47 PM
 */
require_once __DIR__ . '/src/EncryptionHelper.php';
print
'For more complete testing examples see the PHPSpec in specs/Spec/' . PHP_EOL;
$encryptedData = 'F7EBC908B106D4282FA705D0EED915DBE002774B1A152DCC';
print
'$encryptedData = ' . $encryptedData . PHP_EOL;
$eh = new \EncryptionHelper\EncryptionHelper($encryptedData);
$toString = $eh . '';
print
'$toString = ' . $toString . PHP_EOL;
$encrypted = $eh->encrypt($toString);
print
'$encrypted = ' . $encrypted . PHP_EOL;
if (
$encrypted === $encryptedData) {
    print
'Good, the encryption worked right.' . PHP_EOL;
} else {
    print
'Sad, the encryption did not work right.' . PHP_EOL;
}
$decrypted = $eh->decrypt($encrypted);
print
'$decrypted = ' . $decrypted . PHP_EOL;
if (
$decrypted === $toString) {
    print
'Great! Got back what we started with.';
} else {
    print
'Oops! Did not get back what we started with.';
}