How To Encrypt Text In PHP
In this tutorial we will discuss How To Encrypt Text In PHP.Text or a password encryption can be done very easily using the functions md5() or sha1() or crypt() in php.
Encrypt Using MD5
01 | <html> |
02 | <head> |
03 | <title>How To Encrypt Text In PHP</title> |
04 | <style type= "text/css" > |
05 | body |
06 | { |
07 | width: 980px; |
08 | margin: 0px auto; |
09 | text-align: center; |
10 | padding-top: 50px; |
11 | font-size: 20px; |
12 | } |
13 | </style> |
14 | </head> |
15 | <body> |
16 | <h2>How To Encrypt Text In PHP</h2> |
17 | <br><br> |
18 | <?php |
19 | $var = "Hightechnology" ; |
20 | $enc = md5( $var ); |
21 | echo "Encrypted Text - $enc" ; |
22 | ?> |
23 | </body> |
24 | </html> |
Encrypt Using SHA1 (US Secure Hash Algorithm 1)
01 | <html> |
02 | <head> |
03 | <title>How To Encrypt Text In PHP</title> |
04 | <style type= "text/css" > |
05 | body |
06 | { |
07 | width: 980px; |
08 | margin: 0px auto; |
09 | text-align: center; |
10 | padding-top: 50px; |
11 | font-size: 20px; |
12 | } |
13 | </style> |
14 | </head> |
15 | <body> |
16 | <h2>How To Encrypt Text In PHP</h2> |
17 | <br><br> |
18 | <?php |
19 | $var = "Hightechnology" ; |
20 | $enc = sha1( $var ); |
21 | echo "Encrypted Text - $enc" ; |
22 | ?> |
23 | </body> |
24 | </html> |
Encrypt Using Unix DES-based encryption algorithm
01 | <html> |
02 | <head> |
03 | <title>How To Encrypt Text In PHP</title> |
04 | <style type= "text/css" > |
05 | body |
06 | { |
07 | width: 980px; |
08 | margin: 0px auto; |
09 | text-align: center; |
10 | padding-top: 50px; |
11 | font-size: 20px; |
12 | } |
13 | </style> |
14 | </head> |
15 | <body> |
16 | <h2>How To Encrypt Text In PHP</h2> |
17 | <br><br> |
18 | <?php |
19 | $var = "Hightechnology" ; |
20 | $enc = crypt( $var ); |
21 | echo "Encrypted Text - $enc" ; |
22 | ?> |
23 | </body> |
24 | </html> |