Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML class CRSA { // p q private $p =0x0; private $q =0x0; // n(p,q), ph(p,q) private $ph =0x0; private $n =0x0; // private $e =0x0; private $d =0x0; // private $decriptedData = "" ; private $encriptedData = array (); function __construct( $p =0x0, $q =0x0) { $this ->initPQParams( $p , $q ); } // n ph function initPQParams( $p =0x0, $q =0x0) { $this ->p= $p ; $this ->q= $q ; if ( $this ->p && $this ->q && ( $this ->q!= $this ->p)) { $this ->n= $this ->p* $this ->q; $this ->ph=( $this ->p- 1 )*( $this ->q- 1 ); } } // function initEncryptingKey( $e =0x0) { if (! $this ->ph || ! $e ) return false ; $this ->e= $e ; while (! $this ->isMutuallyDistinct( $this ->e, $this ->ph)) $this ->e+= 2 ; return true ; } // private function isMutuallyDistinct( $a , $b ) { while (( $a !=0x0) && ( $b !=0x0)) if ( $a >= $b ) $a = $a % $b ; else $b = $b % $a ; return (( $a + $b )== 1 )? true : false ; } // // function generateDecripringKey() { $u1 = 1 ; $u2 =0x0; $u3 = $this ->ph; $r1 =0x0; $r2 = 1 ; $r3 = $this ->e; while ( $r3 ) { if (! $r3 ) break ; $q =(int)(((int) $u3 )/((int) $r3 )); $t1 =( $u1 - $r1 * $q ); $t2 =( $u2 - $r2 * $q ); $t3 =( $u3 - $r3 * $q ); $u1 = $r1 ; $u2 = $r2 ; $u3 = $r3 ; $r1 = $t1 ; $r2 = $t2 ; $r3 = $t3 ; } $this ->d= $u2 ; } // function getEncripringKey() { return $this ->e; } // function getDecriptingKey( $forced = false ) { if ((! $this ->d) || ( $forced )) { $this ->d=0x0; $this ->generateDecripringKey(); } return $this ->d; } // - , // , - // n(p,q); function EncriptX( $data , $e =0x0, $n =0x0) { if ( $e >0x0 && $n >0x0) { $this ->n= $n ; $this ->e= $e ; } for ( $j =0x0; $j <strlen( $data ); $j ++) { $b =ord( $data [ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->e; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->encriptedData[ $j ]= $result ; } } // - function DecriptX( $d =0x0, $n =0x0) { if ( $d >0x0 && $n >0x0) { $this ->d= $d ; $this ->n= $n ; } $result = 1 ; for ( $j =0x0; $j <count( $this ->encriptedData); $j ++) { $b =( $this ->encriptedData[ $j ]); $result = 1 ; for ( $i =0x0; $i < $this ->d; $i ++) { $result = ( $result * $b ) % $this ->n; } $this ->decriptedData .= chr( $result ); } return $this ->decriptedData; } }
Copy Source | Copy HTML
- $ rsa = new CRSA ( 47 , 71 );
- if ( $ rsa -> initEncryptingKey ( 79 ))
- {
- $ rsa -> EncriptX (“Damn, how everything is complicated”);
- echo "\ n" ;
- $ rsa -> getDecriptingKey ( true );
- echo $ rsa -> DecriptX ();
- echo "\ n" ;
- }
Copy Source | Copy HTML
- $ rsa = new CRSA ();
- $ rsa -> EncriptX ( "Damn, how everything is complicated" , 79 , 3337 );
- echo "\ n" ;
- echo $ rsa -> DecriptX ( 1019 , 3337 );
- echo "\ n" ;
Source: https://habr.com/ru/post/61400/
All Articles