Not everyone can afford a encoder or trust them, so why not create your own basic encoder! In this tutorial i will show you how to encode letters into another letter of your choice. For example the letter “a” will be known as letter “f” and so on.
First of all i wrote out all the letters on paper and then wrote another letter above it which will be the replacement letter for it.
Now what this script will do is encode the word you submit in the form. For example i submitted my name “Shabbir” which was encoded to “ocettyl”. Let me explain it a little more. The letters are mixed around to make a completely different word. Using this method you could send encoded messages & decode it.
In the same method i used to encode the letters i used it to create the function to decode it as well. So you can send a message or password’s/urls ect to family/friends/clients and just tell them to use your decoder to decode it
Now for the main course the code!
<?php
// Copyright PHP2k.com
// Get the message from the url and change it to lowercasing
$x = strtolower($_REQUEST['x']);
//Change the letters to something else, “a” is now “e”, “b” is now “t” ect….
Function Encode($x) {
$rand = array(”a” => “e”, “b” => “t”, “c” => “w”, “d” => “p”, “e” => “m”, “f” => “a”, “g” => “s”, “h” => “c”,
“i” => “y”, “j” => “v”, “k” => “r”, “l” => “q”, “m” => “u”, “n” => “d”, “o” => “h”, “p” => “g”, “q” => “j”,
“r” => “l”, “s” => “o”, “t” => “n”, “v” => “f”, “u” => “b”, “w” => “i”, “x” => “k”, “y” => “z”, “z” => “x”);
$encode = strtr($x, $rand);
echo $encode;
}
//Decode the lettering again so you get the orignal message, so “e” is changed back to “a” ect..
Function Decode($x) {
$rand = array(”e” => “a”, “t” => “b”, “w” => “c”, “p” => “d”, “m” => “e”, “a” => “f”, “s” => “g”, “c” => “h”,
“y” => “i”, “v” => “j”, “r” => “k”, “q” => “l”, “u” => “m”, “d” => “n”, “h” => “o”, “g” => “p”, “j” => “q”,
“l” => “r”, “o” => “s”, “n” => “t”, “f” => “v”, “b” => “u”, “i” => “w”, “k” => “x”, “z” => “y”, “x” => “z”);
$decode = strtr($x, $rand);
echo $decode;
}
?>
<p>
Encode: <br />
<form action=”./” method=”get”>
<textarea col=”2″ rows=”2″ name=”x”></textarea><br />
<input type=”hidden” name=”do” value=”e”>
<input type=”submit” value=”submit”>
</form>
</p>
<p>
Decode: <br />
<form action=”./” method=”get”>
<textarea col=”2″ rows=”2″ name=”x”></textarea><br />
<input type=”hidden” name=”do” value=”d”>
<input type=”submit”>
</form>
</p>
<p>
<?php
if($_GET['do'] == e) {
Encode($x);
} elseif($_GET['do'] == d) {
Decode($x);
}
?>
</p>
If you would like help with this, please leave a message and i will contact you back as soon as possible.
Hope you like the tutorial and learnt something.