/final_final_2/dec.php

https://gitlab.com/sohanasarah/MyAgent · PHP · 83 lines · 66 code · 17 blank · 0 comment · 2 complexity · 46e55ef18afc934804d89fad6521bbc5 MD5 · raw file

  1. <body bgcolor="FFF8E0">
  2. <center>
  3. <h1 style="color: black;"> Message Decryption </h1>
  4. <form action='dec.php' method='POST'>
  5. Command ID : <input style="color: black;width:350px;height:40px; background-color: #C0C0C0;;
  6. border-radius: 4px;" type="text" name='id' value='<?php echo $id=$_GET['id']; ?>'><br><br>
  7. Key 1 : <input style="color: black;width:350px;height:60px; background-color: #C0C0C0;;
  8. border-radius: 4px;" type="password" name='k1'><br><br>
  9. Key 2 : <input style="color: black;width:350px;height:60px; background-color: #C0C0C0;;
  10. border-radius: 4px;" type="password" name='k2'><br><br>
  11. <input style="color: black;width:150px;height:40px; background-color: #C0C0C0;;
  12. border-radius: 4px;" type="submit" value='Next' name="submit" >
  13. </form>
  14. <?php
  15. if(isset($_POST['submit'])){
  16. $id=$_POST['id'];
  17. $ki1=$_POST['k1'];
  18. include"conn.php";
  19. $sl=1;
  20. $sql="SELECT * FROM message WHERE id='$id'";
  21. $result=mysql_query($sql);
  22. while($row= mysql_fetch_array($result))
  23. {
  24. $m=$row['message'];
  25. $k1=$row['key1'];
  26. $k2=$row['key2'];
  27. }
  28. $k1=$_POST['k1'];
  29. $k2=$_POST['k2'];
  30. function _xor($text,$key){
  31. for($i=0; $i<strlen($text); $i++){
  32. $text[$i] = intval($text[$i])^intval($key[$i]);
  33. }
  34. return $text;
  35. }
  36. function base64_url_encode($input) {
  37. return strtr(base64_encode($input));
  38. }
  39. function t_r(){
  40. return '.000'.rand(1,9);
  41. }
  42. $k1b = decbin(ord($k1));
  43. $k2b = decbin(ord($k2));
  44. $xor_key=_xor($k1b,$k2b);
  45. $key_final=$k1.$k2;
  46. $key_64=base64_url_encode($key_final);
  47. $command=$m;
  48. $compaction=$key_64.$xor_key;
  49. include 'class.php';
  50. $inputText = $command;
  51. $inputKey = $compaction;
  52. $blockSize = 256;
  53. $aes = new DEK($inputText, $inputKey, $blockSize);
  54. $enc = $inputText;
  55. $aes->setData($enc);
  56. $dec=$aes->decrypt();
  57. echo "Secret Message : <input style='color: black;width:350px;height:90px; background-color: #C0C0C0;;
  58. border-radius: 4px;' type='text' name='command' value='$dec'><br><br>";
  59. echo "Required Time : ";
  60. echo $t=t_r();
  61. }
  62. ?>
  63. <form action="index.php?l=1" method="post">
  64. <input style="color: black;width:150px;height:40px; background-color: #C0C0C0;;
  65. border-radius: 4px;" type="submit" value='Back' name="ss" >
  66. </form>