Beruflich Dokumente
Kultur Dokumente
php
<?php
use KKiernan\CaesarCipher;
require dirname(__DIR__).'/vendor/autoload.php';
$plaintext = 'Once upon a midnight dreary, while I pondered, weak and weary,
."------------------\n"
.$ciphertext
."\n\n";
$keyGuess = $cipher->crack($ciphertext);
."------------------\n"
.$keyGuess
."\n\n";
."------------------------\n"
.$cipher->decrypt($ciphertext, $keyGuess);
#file prompt.php
<?php
use KKiernan\CaesarCipher;
require dirname(__DIR__).'/vendor/autoload.php';
$continue = true;
/*
|---------------------------------------------------------------------
| Encrypt Message
|---------------------------------------------------------------------
*/
function encrypt()
global $cipher;
$plaintext = fgets(STDIN);
$key = fgets(STDIN);
/*
|---------------------------------------------------------------------
| Crack Ciphertext
|---------------------------------------------------------------------
*/
function crack()
global $cipher;
$ciphertext = fgets(STDIN);
$key = $cipher->crack($ciphertext);
/*
|---------------------------------------------------------------------
| Main Loop
|---------------------------------------------------------------------
*/
while ($continue) {
$selection = fgets(STDIN);
switch ($selection) {
case 1:
encrypt();
break;
case 2:
crack();
break;
case 3:
$continue = false;
echo 'Goodbye!';
break;
default:
break;
<?php
use KKiernan\CaesarCipher;
require dirname(__DIR__).'/vendor/autoload.php';
$key = 12;
$encrypted = $cipher->encrypt('You\'re two handfuls of soil thrown against the pavement. Why won\'t
you grow?', $key);
echo $encrypted."\n";
echo $decrypted."\n";
#file simple.php