Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function encRSA($M){
- $data[0] =1;
- for($i=0;$i<=35;$i++){
- $rest[$i]=pow($M,1)%119;
- if($data[$i]>119){
- $data[$i+1]=$data[$i]*$rest[$i]%119;
- }else{
- $data[$i+1]=$data[$i]*$rest[$i];
- }
- }
- $get=$data[35]%119;
- return $get;
- }
- private function decRSA($E){
- $data[0] =1;
- for($i=0;$i<=11;$i++){
- $rest[$i]=pow($E,1)%119;
- if($data[$i]>119){
- $data[$i+1]=$data[$i]*$rest[$i]%119;
- }else{
- $data[$i+1]=$data[$i]*$rest[$i];
- }
- }
- $get=$data[11]%119;
- return $get;
- }
- contoh
- // $kalimat = "Bebas lahasxcasdasd";
- // $enc="";
- // for($i=0;$i<strlen($kalimat);$i++){
- // $m=ord($kalimat[$i]);
- // if($m<119){
- // $enc=$enc.chr($this->encRSA($m));
- // }else{
- // $enc=$enc.$kalimat[$i];
- // }
- // }
- // $dec="";
- // for($i=0;$i<strlen($enc);$i++){
- // $m=ord($enc[$i]);
- // if($m<119){
- // $dec=$dec.chr($this->decRSA($m));
- // }else{
- // $dec=$dec.$enc[$i];
- // }
- // }
Add Comment
Please, Sign In to add comment