The bare bones of encryption, remember to encrypt incoming and compare against the encrypted version.
You can include the salt in another file, if you like.
1 2 3 4 5 6 7 8 9 10 |
$salt = 'myencryptionkey'; $string = 'password'; $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($salt), $string, MCRYPT_MODE_CBC, md5(md5($salt)))); $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($salt))), "\0"); echo $encrypted; echo $decrypted; |