I have a lua script that encrypts a string and sends it via http to a PHP script. Problem is, the encryption process uses Lua's math.randomseed
and math.random
. When trying to decrypt the string in PHP, mt_srand
and mt_rand
produce different numbers than Lua did.
How can I get php to generate numbers like Lua?
-- Edit
Ok, so in my (very simple) encryption I'm using a key to generate a seed. That seed lets me get back the same "random number" each time.
So if my key produces a seed of say, 80 and I use this in Lua...
math.randomseed(80)
local randomNumber = math.random(1, 20)
// randomNumber = 3
When trying to decrypt in PHP, I'll use the same seed but I get a different output.
mt_srand(80);
$randomNumber = mt_rand(1, 20);
// $randomNumber = 10
I need to figure out a way to get back the same number so that I'm able to decrypt the string.