All pastes #1360074 Raw Edit

henke37

public php v1 · immutable
#1360074 ·published 2009-03-13 18:30 UTC
rendered paste body
<?phpclass encryption_sqrt extends encryption{	private $key;		function __construct(key $key) {		$this->key=$key;	}		function encrypt($data) {		$o='';		for($i=0;$i<strlen($data);++$i) {				$x=ord($data[$i]);			$b=$this->key->getint(0,399);			//$x*=$this->key->getint(0,1)?1:-1;					$c= -($x*($x+$b));						$o.=sprintf('%d,',$c);		}			return substr($o,0,-1);			}		// ax^2+xb+c=0		function decrypt($data) {			$data=explode(',',$data);		$o='';				foreach($data as $c) {			$b=$this->key->getint(0,399);			$x=ceil(($b-sqrt($b*$b-$c*4))/-2);			//$x*=$this->key->getint(0,1)?1:-1;//will undo the invertion			$o.=chr($x);		}				return $o;		}}//user_error('Encryption_sqrt is concidered broken and shall not be used.');