I want to rewrite this python into PHP, how to break it? Solve
天蓬老师
天蓬老师 2017-05-16 13:01:43
0
1
550
  • python code

#!/usr/bin/env python
#coding=utf-8
text = 'odd9xifHtMbFIDSY'
pubKey = '010001'
modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725 152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312e cbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d8 13cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
text = text[::-1]
rs = int(text.encode('hex'), 16)**int(pubKey, 16)%int(modulus, 16)
r = format(rs, 'x').zfill(256)
print r
  • I tried to write php myself, but failed. Please help me analyze the specific reasons.

$text = 'odd9xifHtMbFIDSY';
$pubKey = '010001';
$modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725 152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312e cbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d8 13cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7';

$_text = strrev($text);

// Convert hexadecimal to decimal
$biText = intval(bin2hex($_text),16);
$biEx = intval($pubKey, 16);
$biMod = intval($modulus, 16);

// First square, then take the modulo, and then convert to hexadecimal
$biRet = dechex(fmod(pow($biText,$biEx), $biMod));


// Convert decimal to hexadecimal,
while(strlen($biRet) < 256){
    $biRet = '0' . $biRet;
}

echo $biRet;

The maximum value converted by intval is 9223372036854775807. $biText and $biMod are equal, and they are all equal to the maximum value.
$biRet ='NAN', the calculation estimate is out of range.

< /p>

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
滿天的星座

https://github.com/phpmath/bi...
phpbigint can take a look

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template