Login   Register  
PHP Classes
elePHPant
Icontem

need a help

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

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

  1. need a help   Reply  
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  
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);
}