Hi I have this code that encrypts password and/or username. I'm trying to learn a better way of coding so I ask this question and sorry If this is one of those elementary questions.
I followed this steps stated in another post This one and I want to display (for testing purposes only if what I did was right) It does not need to be username or password, just a plain text inserted in an input box will do as long as I can see if what i entered is encrypted using my code. Please help me out. Stuck for like forever in this scenario.
Now here's my code.
MCrypt.php(just copied it)
<?php 
    class MCrypt
    {
            private $iv = 'fedcba9876543210'; #Same as in JAVA
            private $key = '0123456789abcdef'; #Same as in JAVA
            function __construct()
            {
            }
            function encrypt($str) {
              //$key = $this->hex2bin($key);    
              $iv = $this->iv;
              $td = mcrypt_module_open('rijndael-128', '', 'cbc', $iv);
              mcrypt_generic_init($td, $this->key, $iv);
              $encrypted = mcrypt_generic($td, $str);
              mcrypt_generic_deinit($td);
              mcrypt_module_close($td);
              return bin2hex($encrypted);
            }
            function decrypt($code) {
              //$key = $this->hex2bin($key);
              $code = $this->hex2bin($code);
              $iv = $this->iv;
              $td = mcrypt_module_open('rijndael-128', '', 'cbc', $iv);
              mcrypt_generic_init($td, $this->key, $iv);
              $decrypted = mdecrypt_generic($td, $code);
              mcrypt_generic_deinit($td);
              mcrypt_module_close($td);
              return utf8_encode(trim($decrypted));
            }
            protected function hex2bin($hexdata) {
              $bindata = '';
              for ($i = 0; $i < strlen($hexdata); $i += 2) {
                    $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
              }
              return $bindata;
            }
    }
?>
Here's my submit .php which I don't know if it's correct or not but when I try it show these error
Notice: Use of undefined constant MCrypt - assumed 'MCrypt' in    C:\xampp\htdocs\HSC\submit.php on line 2
Notice: Use of undefined constant php - assumed 'php' in C:\xampp\htdocs\HSC\submit.php   on line 2
Warning: include(MCryptphp): failed to open stream: No such file or directory in C:\xampp\htdocs\HSC\submit.php on line 2
Warning: include(): Failed opening 'MCryptphp' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\HSC\submit.php on line 2
Fatal error: Class 'MCrypt' not found in C:\xampp\htdocs\HSC\submit.php on line 4
Here's my submit.php
<?php
include(MCrypt.php);
$mcrypt = new MCrypt();
#Encrypt
$encrypted = $mcrypt->encrypt('fruit1');
?>
and my index.php
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="submit.php">
<input type="text" id="fruit1">
<input type="text" id="fruit2">
<input type="submit" id="submitfruit" name="clickme">
</form>
</body>
</html>
 
     
    