BimoSora

decrypt

May 4th, 2020
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <form class="log-in-form" action="" method="post">
  2. <div class="text-center"><img src="https://img.icons8.com/bubbles/50/000000/gender-neutral-user.png"></div>
  3. <label>Nama pengguna
  4. <input name="user_username" type="text" placeholder="Minimal harus 4 huruf dan angka" pattern="[a-zA-Z0-9]{4,}" title="Minimal harus 4 huruf dan angka tanpa spasi. a-z A-Z 0-9" oninvalid="this.setCustomValidity('Minimal harus 4 huruf dan angka tanpa spasi. a-z A-Z 0-9')" required>
  5. </label>
  6. <label><b>Kata sandi</b>
  7. <input type="password" id="myInput" name="user_password2" placeholder="Minimal harus 8 huruf dan angka" pattern=".{8,}" title="Minimal harus 8 huruf dan angka" oninvalid="this.setCustomValidity('Minimal harus 8 huruf dan angka')" required>
  8. </label>
  9. <div class="show-password4 password4"><input type="checkbox" onclick="myFunction()"></div> &nbsp; Lihat kata sandi
  10. <br/>
  11. <br/>
  12. <div class="text-center">
  13. <p>
  14. <button class="button primary" type="submit" name="submit" value="data">Masuk</button>
  15. </p>
  16. </div>
  17. <?php
  18. session_start();
  19. require_once("../connection/connection.php");
  20.  
  21. if ($_POST['submit']) {
  22.  
  23. $user_username = htmlentities($_POST['user_username']);
  24. $user_password2 = $_POST['user_password2'];
  25.  
  26. $sql = "SELECT * FROM tw_user WHERE user_username = '$user_username'";
  27. $query = $db->query($sql);
  28. $hasil = $query->fetch(PDO::FETCH_ASSOC);
  29.  
  30. $pass = $hasil['user_password'];
  31.  
  32. list($pass, $enc_iv) = explode("::", $pass);
  33. $cipher_method = 'aes-256-ctr';
  34. $key = $hasil['key_generate'];
  35. $enc_key = openssl_digest($key, 'SHA512', TRUE);
  36. $token = openssl_decrypt($pass, $cipher_method, $enc_key, 0, hex2bin($enc_iv));
  37.  
  38. if($user_username <> $hasil['user_username']) {
  39. echo "<div class='text-center'>Nama pengguna Belum Terdaftar! <a href='../id/masuk'>Kembali</a></div>";
  40. } else {
  41. if($token <> $user_password2) {
  42. echo "<div class='text-center'>Kata sandi salah! <a href='../id/masuk'>Kembali</a></div>";
  43. } else {
  44. $_SESSION['user_id'] = htmlentities($hasil['user_id']);
  45. $_SESSION['user_username'] = htmlentities($hasil['user_username']);
  46. $_SESSION['group_name'] = htmlentities($hasil['group_name']);
  47. $_SESSION['user_name'] = htmlentities($hasil['user_name']);
  48.  
  49. if($_SESSION['group_name'] == 'Administrator')
  50. echo '<div class="text-center">Mengarahkan ke halaman Admin <meta http-equiv="Refresh" Content="1; URL=../id/admin/"></div>';
  51. if ($_SESSION['group_name'] == 'Member')
  52. echo '<div class="text-center">Mengarahkan ke halaman Member <meta http-equiv="Refresh" Content="1; URL=../id/member/"></div>';
  53. }
  54. }
  55. }
  56. ?>
Add Comment
Please, Sign In to add comment