How to Convert Text to Crc32, md5 and Sha1 in PHP
Submitted by alpha_luna on Tuesday, June 14, 2016 - 14:52.
In this tutorial, we are going to learn how to Convert Text to Crc32, md5, and Sha1 in PHP. You will know which is the roughest among the three in terms of the length they generate individually. CRC32 creates a 32-bit hash, md5 creates a 128-bit hash, and Sha1 creates 160-bit (20-byte) hash value. You can use these three to encrypt password from the registering system.
Related code: Convert Text in Sha1
Related code: Convert Text in CRC32
Related code: Convert Text in md5
Creating simple TextBox, buttons, and another TextBox for viewing the result of CRC32, Sha1, and md5 to the form field as in the image below.
Here's the source code of the image above.
For the conversion of text to CRC32, Sha1, and md5 we are going to put this PHP query to the TextBox to view the result.
This is the PHP query.
Here's the result.
The complete source code.
Related code: Convert Text in Sha1
Related code: Convert Text in CRC32
Related code: Convert Text in md5
Hope that this tutorial will help you a lot.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
- <center>
- <div style="border:2px solid blue; background:azure; width:500px; padding:20px;">
- <form method="post">
- <input type="text" name="convert" style="padding:5px; font-size:18px; width:245px; font-family:cursive;" placeholder="Type Anything . . . . ." autofocus="autofocus">
- <input type="submit" name="convertion" value="Convert" style="padding:5px; font-family:cursive; font-size:18px; color:blue; background:azure; border:1px solid blue; border-radius:4px; cursor:pointer;">
- </form>
- <br>
- <input type="text" value="" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <input type="text" value="" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <input type="text" value="" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- </div>
- </center>
Now, let's put to the TextBox.
- <input type="text" value="<?php if(isset($_POST['convertion'])){ echo crc32($_POST['convert']); } ?>" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <input type="text" value="<?php if(isset($_POST['convertion'])){ echo sha1($_POST['convert']); } ?>" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <input type="text" value="<?php if(isset($_POST['convertion'])){ echo md5($_POST['convert']); } ?>" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <!DOCTYPE html>
- <html>
- <head>
- </head>
- <body>
- <center>
- <div style="border:2px solid blue; background:azure; width:500px; padding:20px;">
- <form method="post">
- <input type="text" name="convert" style="padding:5px; font-size:18px; width:245px; font-family:cursive;" placeholder="Type Anything . . . . ." autofocus="autofocus">
- <input type="submit" name="convertion" value="Convert" style="padding:5px; font-family:cursive; font-size:18px; color:blue; background:azure; border:1px solid blue; border-radius:4px; cursor:pointer;">
- </form>
- <br>
- <input type="text" value="<?php if(isset($_POST['convertion'])){ echo crc32($_POST['convert']); } ?>" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <input type="text" value="<?php if(isset($_POST['convertion'])){ echo sha1($_POST['convert']); } ?>" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- <input type="text" value="<?php if(isset($_POST['convertion'])){ echo md5($_POST['convert']); } ?>" style="padding:5px; text-align:center; border:1px solid blue; color:blue; font-size:18px; background:azure; cursor:not-allowed; width:480px; " readonly>
- </div>
- </center>
- </body>
- </html>
Add new comment
- 256 views