here is my problem. I am using BCMATH functions of PHP (here the class I use, and the function Base_Math::obfuscate()) to obfuscate some urls, ids, etc and deobfuscate them.
I am actually programming over windows 8.1 x64 with the last version of XAMPP. Recently I created a virtual machine in my computer wtih vmware based on centOS 6.6 x64 which is the operative system I will have online, to debug problems compabilities between operative system and to have a stage environment to make updates faster.
The problem comes when I go to the vm environment, the functions used from BCMATH gives me as a result different values as it does in windows environment. One of my friends warn me about this could happen but I love risk and lose tons of hours programming :|
What I don't know, if this problem comes because of the operative system, because of the hardware itself or what? Can I modified the function so it gives me back always the same result? If it can't be what would you say it is a good solution to obfuscate your database entities ID?
This is the way I use the method:
//obfuscate number 5
Math_Base::obfuscate(5,false,32,'OndZLj3mby9GpDtbrzDVGPkWR1J1dlC9JPIcsMe1l0YX8lzONTVlkCzDzPb9PJR');
//it returns on windows 8: CsQNlnY5dXMKJXYLFgzxZT85HTzPb2FQ
//in centos YBs1DMzFdhV5JhzlG7NvtxfFmxNkrTGs
Thanks to @Cheery because what he/she said gave me the answer to the problem in the third comment of my question. It was all about srand(). Since I didn't create this class, my great friend did modified it for me. This is the result class
He did change this part (causing the problem):
if ($this->_key !== null) {
//Mezclar los caracteres base usando la clave
srand(crc32($this->_key));
$this->_base = str_shuffle($this->_base_original);
srand(); //Restaurar semilla aleatoria por defecto
}
For this one:
if ($this->_key !== null) {
//Mezclar los caracteres base usando la clave
mt_srand(crc32($this->_key));
$chars = Str::chars($this->_base_original);
for($i = count($chars) - 1; $i > 0; --$i) {
$j = mt_rand(0, $i);
if($i !== $j) {
list($chars[$i], $chars[$j]) = array($chars[$j], $chars[$i]);
}
}
$this->_base= join('', $chars);
mt_srand();//Restaurar semilla aleatoria por defecto
}
So he did avoid any compatibility problem between platforms.
Thanks to everyone who helped here.