I'm curious if there are any PHP programmers around that also program in Visual Basic.

I have a issue. I need some help making the equivalent to the following PHP code in Visual Basic so they are communicate across my database.

<?php
function Encrypt($string, $key)
{
$result = '';
for($i=1; $i<=strlen($string); $i++)
{
$char = substr($string, $i-1, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return $result;
}

function Decrypt($string, $key)
{
$result = '';
for($i=1; $i<=strlen($string); $i++)
{
$char = substr($string, $i-1, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}
?>

Any help appreciated.

    The above PHP code works fine for simple encoding, decoding a string. However is their any way I modify it to use only printable characters (alphanumeric aA-zZ, 0-9)

      Write a Reply...