実際には理論的な部分がここで見つけることができます 。 私はかつてブルース・シュナイアーの本「Applied Cryptography」を使用していました。
コードを準備するには、次のものが必要です。
1. 高度なユークリッドアルゴリズム
2. GCDを見つけるためのアルゴリズム。
3. パワーをパワーに素早く上げるための適応アルゴリズム
なぜなら 準備部分がほぼ完了したら、実装に進むことができます。
次は、アルゴリズムを実装するためのコードと私のコメントです。
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; } }
クラスの実際の実装は次のとおりです。2つの方法で適用できます
メソッドの回数:
Copy Source | Copy HTML
- $ rsa = new CRSA(47、71);
- if ( $ rsa-> initEncryptingKey( 79 ))
- {
- $ rsa-> EncriptX(「くそー、なんて複雑か」);
- echo "\ n" ;
- $ rsa-> getDecriptingKey( true );
- echo $ rsa-> DecriptX();
- echo "\ n" ;
- }
メソッド番号2:
Copy Source | Copy HTML
- $ rsa = 新しい CRSA();
- $ rsa-> EncriptX( "くそー、なんて複雑か、" 79、3337);
- echo "\ n" ;
- echo $ rsa-> DecriptX(1019、3337);
- echo "\ n" ;
謝辞:
記事を公開する機会を与えてくれたユーザーに感謝します。
その他:
ここでこのアルゴリズムの別の実装を見つけることができます 。
ゼロは、パーサーが食べないように16進数で書き込まれます。
UPD:
コメントで正しく指摘されているように、実装は学術的な関心のためであり、 PHPの既存のデータ型の制限は、深刻なキー長での暗号化を許可しません。
ただし、短期間のセッションデータの暗号化はうまく機能する可能性があります。
UPD 2:
また、実装はここにあります ( galaxyユーザーに感謝します)