Ok, so I’m trying to figure out how to go from hexadecimal encryption to string and back, but for some reason the when I encrypt, i’m not getting the same password that was passed in, but its close…weird right? I’m sure my syntax is wrong somewhere. Help?
Here’s a link to test a little random password. I’ve set ‘pw’ as the hexadecimal version and pass that in: view demo
$encoded = (string)$_GET['pw'];
$literals = explode(' ', wordwrap($encoded, 2, ' ', 2));
$password = '';
for ($i = 0; $i < count($literals); $i++) {
$password .= chr(hexdec($literals[$i]) - $i);
}
echo $password . '<br />';
print_r($literals) . '<br />';
$passarray = str_split($password);
echo '<pre>';
print_r($passarray);
echo '</pre>';
for($i = 0; $i < count($passarray); $i++) {
$newpassword .= bin2hex($passarray[$i]);
}
echo $newpassword;
UPDATE:
.I’m actually not trying to “encrypt” for security per se…I’m actually trying to automate the creation of Dreamweaver Site Definition files and this is the “encryption” they use to semi-hide the password. I can do this already by copying the file and inserting different usernames, but I’d like to issue and new password each time as well. just FYI
Look closer at this line:
You’re decreasing the value by
$i. So every increment, the value will be$literals[$i] - $i.This is the reverse of the above: