Security::cipher - Linux and Windows gives different results?!

Any body know how to improve this function
public static function cipher($text, $key) {
if (empty($key)) {
trigger_error(__d(‘cake_dev’, ‘You cannot use an empty key for %s’, ‘Security::cipher()’), E_USER_WARNING);
return ‘’;
$out = ‘’;
$keyLength = strlen($key);
for ($i = 0, $textLength = strlen($text); $i < $textLength; $i++) {
$j = ord(substr($key, $i % $keyLength, 1));
while ($j–) {
rand(0, 255);
$mask = rand(0, 255);
$out .= chr(ord(substr($text, $i, 1)) ^ $mask);
return $out;

and get yhe same results on Windows 64bit and Linux 64bit OS?

As far as I understand, it’s not the function problem, but in the characters placed in $text.
Are you sure that the encoding of the text is the same in both cases?

I think the “problem” is precisely this. :slight_smile:

To accurately verify this, just write a text file in Windows, move it to Linux and look at the encoding.

I think this issue related with OS and PHP (bit version).
As result I’ve changed development environment : Chenged Openserver to VirtualBox + vagrant