My first question here, so hopefully this all goes well.
I have an application that is currently running on desktop under MS Access using VBA code. When the user logs in I have a function to encrypt the password. This is:
Public Function EncryptEasy(strIn As String) As String
Dim strChr As String
Dim i As Integer
Dim Salt As Long
Salt = 543214321
For i = 1 To Len(strIn)
strChr = strChr & CStr(Asc( Mid(strIn, i, 1) ) Xor Salt)
Next I
EncryptEasy = strChr
End Function
To give you an idea, when I run EncryptEasy("test") in VBA, it returns: 543214213543214228543214210543214213
I am now setting up a simple web-app using PHP and was hoping to utilise the same encryption as I'm currently using by coding this function into PHP. I HAVE tried and below is my attempt:
function EncryptEasy($strIn) {
$salt = 543214321;
$strChr = Null;
$strLen = strlen($strIn);
for ($i = 0; $i <= $strLen; $i++) {
$strChr = $strChr . chr(ord(substr($strIn, $i, 1)) xor $salt);
}
return $strChr;
}
However, this is returning blank. I have tried echoing this:
<?php
echo EncryptEasy("test");
?>
to no avail.
Is anyone able to see where I am going wrong?