ENCRYPT$ - php backend

Previous topic - Next topic

Kitty Hello


this is the PHP code you must use to generate the same results as with ENCRYPT$/DECRYPT$.

Please - use _this_ version, not any original copy you can find.

[attachment deleted by admin]


MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC




Does anyone know if this PHP code can be used with non-english characters and Windows-1252 encoding?

Whenever I try to encrypt something like "campeón" ('champion' in Spanish) I get an encrypted string which is a different string than the string GLBasic would give with ENCRYPT$ (so that is not good). But also, when I try to decrypt this encrypted string with GLBasic the app crashes, or if I try to decrypt the string using the PHP function it returns nothing. The same PHP code works perfectly if I don't use special characters (but that is not a solution for me) or if I use UTF-8 instead of Windows-1252, but I think we need to use Windows-1252 if we want to use the encrypted string in GLBasic, don't we?

Any help or hint would be much appreciated.

The PHP code I use to test (in case you see something there that I don't):
Code (GLBasic) Select

$obj = new MyBlowfish("MyStrongPswd");
$test = iconv("UTF-8","Windows-1252//TRANSLIT", "campeón");
$testEnc = $obj->encryptString($test);
$testDec = $obj->decryptString($testEnc);
echo("Encrypted: ".$testEnc."<br>Decrypted: ".$testDec);


Use urldecode/encode functions first to convert it to base64 strings. Then it's should work.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/


Thank you for your answer, spacefractal.

Unfortunately, it doesn't seem to completely solve my problem: now first I use urlencode in PHP, then encrypt the string in PHP, and finally send the encrypted string to GLBasic where I get "campe%C3%B3n" instead of "campeón". My GLBasic app doesn't crash, but the resulting texts are unreadable. Is there any other way?


In GLBasic program, did you use URLDECODE$ after DECRYPT$?
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64


Thank you, kanonet. I didn't know there was a URLDECODE$ instruction in GLBasic!

Indeed, I did not use that instruction on my tests. I was hopping to achieve in PHP the very same encryption I get from ENCRYPT$ in GLBasic (I wanted to obtain the same encrypted file no matter what language I used). But it seems that, in order to do so, I'll have to modify my GLBasic code too and insert a URLENCODE$/URLDECODE$ instruction before/after encrypting my texts, respectively. Thank you again for the hints.

Although I assume this is not the optimum choice. Since GLBasic is already capable of encrypting and correctly decrypting "campeón" without having to previously use URLENCODE$, this PHP instruction should be able to do the same, right? Maybe there is a way to update this blowfish.php file so that it can encrypt non-english Windows-1252 characters too?

Anyway, thank you all, again, for your input.


the main issue, me thinks is the server using a different charset page, than that one you using. To prevent chars to been changed, you should only uses English safe chars, which is why you should do a URLDECODE/ENCODE first to prevent various issues.

in php, you can use those (im havent tested it):

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/