<?php
require_once __DIR__ . '/src/EncryptionAtRest.php';

echo "Hello World! Let's test the encryption library.";

// Add a form with a text input and a submit button
?>

<form action="index.php" method="post">
    <input type="text" name="text" placeholder="Enter text to encrypt">
    <button type="submit">Encrypt</button>
</form>

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $text = $_POST['text'];

    $encryption = new EncryptionAtRest();

    $encrypted = $encryption->encrypt($text);

    echo "Encrypted: " . $encrypted . "<br>";

    $decrypted = $encryption->decrypt($encrypted);

    echo "Decrypted: " . $decrypted . "<br>";
    
    echo "Match: " . ($text === $decrypted ? "✓ YES" : "✗ NO");
}
?>


