Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3.     <title>
  4.     Sha1 in action
  5.     </title>
  6. </head>
  7. <body>
  8.     <form action=<?php echo htmlentities($_SERVER['PHP_SELF'],ENT_QUOTES); ?> method="post">
  9.         User <input type="text" name="user" />
  10.             <br />
  11.         Password <input type="password" name="pass" />
  12.             <br />
  13.         Submit<input type="submit" name="submit" />
  14.             <br />
  15.     </form>
  16. </body>
  17. </html>
  18.  
  19. <?php
  20.  
  21. if(isset($_POST['submit']))
  22. {
  23.     // Inputs from $_POST(more suitable to be used in this case)
  24.     $user = $_POST['user'];
  25.     $pass = $_POST['pass'];
  26.  
  27.     // Just assume that this is the settings at your sql db
  28.     $sql['user'] = "cshong"; // you may encrypt your username as well if you really wanted full security, although it is not necessary actually
  29.     $sql['pass'] = "4d7596726ca20476148e8fdb1b4c5f44d719a92b"; // pass in sha1 format
  30.  
  31.     // Execute your sql query to retrieve the $sql data(pardon me on my laziness)
  32.  
  33.     // Encrypt the user input to be compared with the data at the sql db
  34.     $pass_encrypted = sha1($pass);
  35.  
  36.     // after results had been retrieved
  37.     if($user == $sql['user'] and $pass_encrypted == $sql['pass'])
  38.     {
  39.         echo 'yay, I can access my account eventhough the pass is actually in an encrypted form at the sql db';
  40.     }
  41.     else
  42.     {
  43.         die("Go die");
  44.     }
  45. }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement