so I already managed how to decode and encode, this is done via 2 functions. So here is the example
http://goldextra.com/b/id_color.php
If you enter a word, it will get encoded, as shown in the result page. so if one enters = testword the url will be http://goldextra.com/b/balloony.php?name=testword
The thing is, instead I want the url to look like this http://goldextra.com/b/balloony.php?name=k484z52646w5i474 (of course the site itself should not show the encryption, but the word)
How do I have to change the code I have now, and do I have to change code in the Form site or the result site?
FORM CODE
<form action="balloony.php" class="sign-up" method="get" class="sign-up">
<h1 class="sign-up-title">Whats the word?</h1>
<input type="text" class="sign-up-input" placeholder="Enter your baloony" name="name" autofocus>
<input type="submit" value="baloony it!" class="sign-up-button">
RESULT SITE
<?php
function encode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i++) {
$ordStr = ord(substr($string,$i,1));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
}
return $hash;
}
function decode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i+=2) {
$ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= chr($ordStr - $ordKey);
}
return $hash;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo htmlspecialchars($_GET["name"]) . '!'; ?></title>
<style type="text/css">
.BIG {
font-size: 250px;
font-weight: bold;
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
text-align: center;
}
</style>
</head>
<body class="BIG">
<?php
$name = htmlspecialchars($_GET['name']);
$urlENC = encode( $name ,"whateverkey");
$urlDEC = decode( $urlENC ,"whateverkey");
echo htmlspecialchars($_GET["url"]) . '';
echo $urlENC; ?>
<br />
<? echo $urlDEC; ?>