PHP - Simple Password Encryptor

Submitted by: 
Visitors have accessed this post 399 times.

In this tutorial we will create a Simple Password Encryptor Using php. PHP is a server-side scripting language designed primarily for web development. Using PHP, you can let your user directly interact with the script and easily to learned its syntax. It is mostly used by a newly coders for its user friendly environment. So Let's do the coding...

Getting Started:

First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server

And this is the link for the bootstrap that i used for the layout design

Creating The Interface

This is where we will create a simple form for our application. To create the forms simply copy and write it into you text editor, then save it as index.php.

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" name="viewport" content="width=device-width, intial-scale=1" />
  5. <link rel="stylesheet" name="viewport" href="css/bootstrap.css"/>
  6. </head>
  7. <body>
  8. <nav class="navbar navbar-default">
  9. <div class="container-fluid">
  10. <a class="navbar-brand" href="<a href="">Sourcecodester</a>
  11. " rel="nofollow">">Sourcecodester</a>
  12. </a> </div>
  13. </nav>
  14. <div class="col-md-3"></div>
  15. <div class="col-md-6 well">
  16. <h3 class="text-primary">PHP - Simple Password Encryptor</h3>
  17. <hr style="border-top:1px dotted #ccc;"/>
  18. <div class="col-md-2"></div>
  19. <div class="col-md-8">
  20. <form action="" method="POST">
  21. <div class="form-group">
  22. <input type="text" placeholder="Enter your password" name="password" class="form-control" required="required"/>
  23. </div>
  24. <div class="form-group">
  25. <label>Select an encryptor</label>
  26. <select name="encryptor" required="required" class="form-control">
  27. <option value="">Select an option</option>
  28. <option value="md5">md5</option>
  29. <option value="sha1">sha1</option>
  30. <option value="ripemd160">ripemd160</option>
  31. <option value="haval160,4">haval160,4</option>
  32. <option value="sha256">sha256</option>
  33. </select>
  34. </div>
  35. <h4 class="text-success" style="word-wrap:break-word;"><?php include 'encrypt.php'?></h4>
  36. <center><button name="encrypt" class="btn btn-primary">Encrypt</button></center>
  37. </form>
  38. </div>
  39. </div>
  40. </body>
  41. </html>

Creating the Main Function

This code contains the main function of the application. This code will encrypt your password automatically. To do this just copy and write these block of codes as shown below inside the text editor, then save it as encrypt.php.

  1. <?php
  2. if(ISSET($_POST['encryptor'])){
  3. $encryptor = $_POST['encryptor'];
  4. $password = $_POST['password'];
  6. switch($encryptor ){
  7. case "md5":
  8. echo hash("md5", $password);
  9. break;
  10. case "sha1":
  11. echo hash("sha1", $password);
  12. break;
  13. case "ripemd160":
  14. echo hash("ripemd160", $password);
  15. break;
  16. case "haval160,4":
  17. echo hash("haval160,4", $password);
  18. break;
  19. case "sha256":
  20. echo hash("sha256", $password);
  21. break;
  22. }
  23. }
  24. ?>

There you have it we successfully created a Simple Password Encryptor using PHP. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.