/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //$beneficiary = Beneficiary::findOrFail($id);
     //return response()->success(compact('beneficiary'));
     $sender = Sender::findOrFail($id);
     $beneficiary = $sender->sender_beneficiaries()->get();
     return response()->success(compact('beneficiary'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $sender = Sender::findOrFail($id);
     $id = $sender->sender_indentification()->get();
     return response()->success(compact('id'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $sender = Sender::FindOrFail($id);
     //$beneficiaries = $sender->sender_beneficiaries()->get();
     return response()->success(compact('sender'));
 }
Exemplo n.º 4
0
 public function receiverRequest()
 {
     $senders = Sender::all();
     $receivers = Receiver::all();
     foreach ($senders as $sender) {
         $pk_sender = $sender->private_key;
         $encrypted_text = $sender->encrypted_text;
     }
     foreach ($receivers as $receiver) {
         $pk_receiver = $receiver->private_key;
     }
     $r = $pk_sender;
     $s = $pk_receiver;
     $str = $encrypted_text;
     $r1 = pow(3, $r) % 17;
     $s1 = pow(3, $s) % 17;
     $r2 = pow($s1, $r) % 17;
     $s2 = pow($r1, $s) % 17;
     $str1 = "";
     $len = strlen($str);
     for ($y = 0; $y < $len; $y++) {
         //echo $y;
         $swap = 0;
         if ($str[$y] == 'A' || $str[$y] == 'a') {
             $swap = 1;
         }
         if ($str[$y] == 'B' || $str[$y] == 'b') {
             $swap = 2;
         }
         if ($str[$y] == 'C' || $str[$y] == 'c') {
             $swap = 3;
         }
         if ($str[$y] == 'D' || $str[$y] == 'd') {
             $swap = 4;
         }
         if ($str[$y] == 'E' || $str[$y] == 'e') {
             $swap = 5;
         }
         if ($str[$y] == 'F' || $str[$y] == 'f') {
             $swap = 6;
         }
         if ($str[$y] == 'G' || $str[$y] == 'g') {
             $swap = 7;
         }
         if ($str[$y] == 'H' || $str[$y] == 'h') {
             $swap = 8;
         }
         if ($str[$y] == 'I' || $str[$y] == 'i') {
             $swap = 9;
         }
         if ($str[$y] == 'J' || $str[$y] == 'j') {
             $swap = 10;
         }
         if ($str[$y] == 'K' || $str[$y] == 'k') {
             $swap = 11;
         }
         if ($str[$y] == 'L' || $str[$y] == 'l') {
             $swap = 12;
         }
         if ($str[$y] == 'M' || $str[$y] == 'm') {
             $swap = 13;
         }
         if ($str[$y] == 'N' || $str[$y] == 'n') {
             $swap = 14;
         }
         if ($str[$y] == 'O' || $str[$y] == 'o') {
             $swap = 15;
         }
         if ($str[$y] == 'P' || $str[$y] == 'p') {
             $swap = 16;
         }
         $c = $swap;
         // echo " ".$c;
         for ($i = 0; $i <= 17; $i++) {
             if ($s2 * $i % 17 == 1) {
                 $x = $i;
                 break;
             }
         }
         $invi = $x;
         $p = $invi * $c % 17;
         if ($p == 1) {
             $str1 = $str1 . "A";
         }
         if ($p == 2) {
             $str1 = $str1 . "B";
         }
         if ($p == 3) {
             $str1 = $str1 . "C";
         }
         if ($p == 4) {
             $str1 = $str1 . "D";
         }
         if ($p == 5) {
             $str1 = $str1 . "E";
         }
         if ($p == 6) {
             $str1 = $str1 . "F";
         }
         if ($p == 7) {
             $str1 = $str1 . "G";
         }
         if ($p == 8) {
             $str1 = $str1 . "H";
         }
         if ($p == 9) {
             $str1 = $str1 . "I";
         }
         if ($p == 10) {
             $str1 = $str1 . "J";
         }
         if ($p == 11) {
             $str1 = $str1 . "K";
         }
         if ($p == 12) {
             $str1 = $str1 . "L";
         }
         if ($p == 13) {
             $str1 = $str1 . "M";
         }
         if ($p == 14) {
             $str1 = $str1 . "N";
         }
         if ($p == 15) {
             $str1 = $str1 . "O";
         }
         if ($p == 16) {
             $str1 = $str1 . "P";
         }
     }
     foreach ($receivers as $receiver) {
         $receiver->decrypted_text = $str1;
         $receiver->save();
     }
     $xyz = Receiver::all();
     $abc = Sender::all();
     return var_dump($receivers);
     /*return redirect('decrypt', array('receivers' => $receivers));*/
     return view('decrypt')->with(array('receivers' => $xyz, 'senders' => $abc));
 }
Exemplo n.º 5
0
 public function senderRequest()
 {
     $senders = Sender::all();
     $receivers = Receiver::all();
     $messages = Message::all();
     foreach ($senders as $sender) {
         $pk_sender = $sender->private_key;
     }
     foreach ($receivers as $receiver) {
         $pk_receiver = $receiver->private_key;
     }
     foreach ($messages as $message) {
         $v = $message->text_message;
     }
     $str = "";
     $len = strlen($v);
     for ($y = 0; $y < $len; $y++) {
         $swap = 0;
         if ($v[$y] == 'A' || $v[$y] == 'a') {
             $swap = 1;
         }
         if ($v[$y] == 'B' || $v[$y] == 'b') {
             $swap = 2;
         }
         if ($v[$y] == 'C' || $v[$y] == 'c') {
             $swap = 3;
         }
         if ($v[$y] == 'D' || $v[$y] == 'd') {
             $swap = 4;
         }
         if ($v[$y] == 'E' || $v[$y] == 'e') {
             $swap = 5;
         }
         if ($v[$y] == 'F' || $v[$y] == 'f') {
             $swap = 6;
         }
         if ($v[$y] == 'G' || $v[$y] == 'g') {
             $swap = 7;
         }
         if ($v[$y] == 'H' || $v[$y] == 'h') {
             $swap = 8;
         }
         if ($v[$y] == 'I' || $v[$y] == 'i') {
             $swap = 9;
         }
         if ($v[$y] == 'J' || $v[$y] == 'j') {
             $swap = 10;
         }
         if ($v[$y] == 'K' || $v[$y] == 'k') {
             $swap = 11;
         }
         if ($v[$y] == 'L' || $v[$y] == 'l') {
             $swap = 12;
         }
         if ($v[$y] == 'M' || $v[$y] == 'm') {
             $swap = 13;
         }
         if ($v[$y] == 'N' || $v[$y] == 'n') {
             $swap = 14;
         }
         if ($v[$y] == 'O' || $v[$y] == 'o') {
             $swap = 15;
         }
         if ($v[$y] == 'P' || $v[$y] == 'p') {
             $swap = 16;
         }
         $m = $swap;
         $r = $pk_sender;
         $s = $pk_receiver;
         $r1 = pow(3, $r) % 17;
         $s1 = pow(3, $s) % 17;
         $r2 = pow($s1, $r) % 17;
         $s2 = pow($r1, $s) % 17;
         $c = $r2 * $m % 17;
         if ($c == 1) {
             $str = $str . "A";
         }
         if ($c == 2) {
             $str = $str . "B";
         }
         if ($c == 3) {
             $str = $str . "C";
         }
         if ($c == 4) {
             $str = $str . "D";
         }
         if ($c == 5) {
             $str = $str . "E";
         }
         if ($c == 6) {
             $str = $str . "F";
         }
         if ($c == 7) {
             $str = $str . "G";
         }
         if ($c == 8) {
             $str = $str . "H";
         }
         if ($c == 9) {
             $str = $str . "I";
         }
         if ($c == 10) {
             $str = $str . "J";
         }
         if ($c == 11) {
             $str = $str . "K";
         }
         if ($c == 12) {
             $str = $str . "L";
         }
         if ($c == 13) {
             $str = $str . "M";
         }
         if ($c == 14) {
             $str = $str . "N";
         }
         if ($c == 15) {
             $str = $str . "O";
         }
         if ($c == 16) {
             $str = $str . "P";
         }
     }
     foreach ($senders as $sender) {
         $sender->encrypted_text = $str;
         $sender->save();
     }
     return redirect('/sender');
 }