Welcome! Log In Create A New Profile

Advanced

encryption

Posted by Piet van Zanten 
Piet van Zanten
encryption
December 16, 2008 01:50PM
Hi All,

I am trying to find a compatible way to encrypt and decrypt strings (passwords) between Windev and PHP. The security is a minor issue, so simplicity prevails.
I found a nice and simple php function to crypt and decrypt that uses base_64encode:
function encode5t($str)
{
  for($i=0; $i<5;$i++)
  {
    $str=strrev(base64_encode($str)); //apply base64 first and then reverse the string
  }
  return $str;
}
To decode there's a similar function that reverses the process.
If I try to duplicate this code in Windev, I stumble upon the fact that Windev insists on using a passfrase for the Crypt function if using the encodeBase64 constant.

Any other ideas how to create password encryption/decryption that can be used in Windev AND php?

Best regards,
Piet




Edited 1 time(s). Last edit at 12/16/2008 01:52PM by Piet van Zanten.
Alexandre Leclerc
Re: encryption
December 16, 2008 04:50PM
Hi Piet,

This works just as expected.

s is string = Crypt("This is an encoded string","",cryptNone,encodeBASE64)
Trace(s)
Trace(s="VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==") // [ca.php.net]
Trace(Uncrypt(s,"",cryptNone,encodeBASE64))

Hope this helps.

Best regards.
Piet van Zanten
Re: encryption
December 16, 2008 06:00PM
Thanks Alexandre,

I forgot the cryptNone. And the reverse function in Windev is different from strrev in php.
In windev:
x=edt_Edit1
FOR i=1 TO 5
	y=Crypt(x,"",cryptNone,encodeBASE64)
	x=""
	FOR j=Length(y) TO 1 STEP -1
		x+=y[[j]]
	END
END
edt_Edit2=x

Regards,
Piet



Edited 3 time(s). Last edit at 12/16/2008 06:07PM by Piet van Zanten.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: