Skip to content

Instantly share code, notes, and snippets.

@dessso
Created August 31, 2014 20:05
Show Gist options
  • Save dessso/b9b3588eed38445774a0 to your computer and use it in GitHub Desktop.
Save dessso/b9b3588eed38445774a0 to your computer and use it in GitHub Desktop.
PHP exam 29 August Evening 01. Email Encryptor
<?php
$recipient = $_GET['recipient'];
$subject = $_GET['subject'];
$body = $_GET['body'];
$key = $_GET['key'];
$formattedRecipient = htmlspecialchars($recipient);
$formattedSubject = htmlspecialchars($subject);
$formattedBody = htmlspecialchars($body);
$formattedMessage = "<p class='recipient'>$formattedRecipient</p><p class='subject'>$formattedSubject</p><p class='message'>$formattedBody</p>";
$key2 = $key;
$newKey = str_pad($key, strlen($formattedMessage), $key2);
for ($i = 0; $i < strlen($formattedMessage); $i++) {
$item = ord ($formattedMessage[$i]) * ord ($newKey[$i]);
$hex = dechex($item);
echo "|" . $hex;
}
echo "|";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment