Created
August 31, 2014 20:05
-
-
Save dessso/b9b3588eed38445774a0 to your computer and use it in GitHub Desktop.
PHP exam 29 August Evening 01. Email Encryptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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