Categories
PHP

How To Encrypt Text In PHP

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

<html>
<head>
<title>How To Encrypt Text In PHP</title>
<style type="text/css">
body
{
width: 980px;
margin: 0px auto;
text-align: center;
padding-top: 50px;
font-size: 20px;
}
</style>
</head>
<body>
<h2>How To Encrypt Text In PHP</h2>
<br><br>
<?php
$var = "Hightechnology";
$enc = md5($var);
echo "Encrypted Text - $enc";
?>
</body>
</html>

Encrypt Using SHA1 (US Secure Hash Algorithm 1)

<html>
<head>
<title>How To Encrypt Text In PHP</title>
<style type="text/css">
body
        {
            width: 980px;
            margin: 0px auto;
            text-align: center;
            padding-top: 50px;
            font-size: 20px;
        }
</style>
</head>
<body>
<h2>How To Encrypt Text In PHP</h2>
<br><br>
<?php
$var = "Hightechnology";
$enc = sha1($var);
echo "Encrypted Text - $enc";
?>
</body>
</html>

Encrypt Using Unix DES-based encryption algorithm

<html>
<head>
    <title>How To Encrypt Text In PHP</title>
    <style type="text/css">
        body
        {
            width: 980px;
            margin: 0px auto;
            text-align: center;
            padding-top: 50px;
            font-size: 20px;
        }
    </style>
</head>
<body>
<h2>How To Encrypt Text In PHP</h2>
<br><br>
<?php
$var = "Hightechnology";
$enc = crypt($var);
echo "Encrypted Text - $enc";
?>
</body>
</html>