Ardhn Mohammed - 2013-07-01 05:29:23 -
In reply to message 1 from aroma
Modify it to be like this
public function encrypt ($m, $e, $n, $s=3) {
$coded = '';
$max = strlen($m);
$packets = ceil($max/$s);
for($i=0; $i<$packets; $i++){
$packet = substr($m, $i*$s, $s);
$code = '0';
for($j=0; $j<$s; $j++){
$X = substr($packet,$j,1);
$code = bcadd($code, bcmul(ord($X), bcpow('256',$j)));
}
$code = bcpowmod($code, $e, $n);
$coded .= $code.' ';
}
return trim($coded);
}