PHP Classes

need a help

Recommend this page to a friend!

      RSA  >  All threads  >  need a help  >  (Un) Subscribe thread alerts  
Subject:need a help
Summary:Uninitialized string offset
Date:2011-04-17 20:12:05
Update:2013-07-01 05:29:23

  1. need a help   Reply   Report abuse  
Picture of aroma aroma - 2011-04-17 20:12:12
first, thanks for your useful work. it's really helpful and so clear. but when i tried the example it showed this notice:

Uninitialized string offset...

it seems to be in this line:

$code = bcadd($code, bcmul(ord($packet[$j]), bcpow('256',$j)));

please, I need your help ASAP, I'm working on my senior project.

thanks in advance

  2. Re: need a help   Reply   Report abuse  
Picture of Ardhn Mohammed 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);

  3. Thanking   Reply   Report abuse  
Picture of Shaam Shaam - 2014-12-30 16:51:31 - In reply to message 2 from Ardhn Mohammed
Thank you very much. This helps to solve the problem