I am creating an application that will store passwords, which the user can retrieve and see. The passwords are for a hardware device, so checking against hashes are out of
I tried something like this but please note that I am not cryptographer nor I hold in-depth knowledge about php or any programming language. It's just an idea. My idea is to store key in some file or database (or enter manually) which(location) cannot be easily predicted(And of course anything will be decrypted someday, the concept is to lengthen the decryption time) and encrypt sensitive information.
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH , MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$key = "evenifyouaccessmydatabaseyouwillneverfindmyemail";
$text = "myemail@domain.com";
echo "Key : ".$key."
";
echo "Text : ".$text . "
";
echo "Md5 : ".md5($text). "
";
echo "Sha1 : ".sha1($text). "
";
$crypttext = mcrypt_encrypt(MCRYPT_BLOWFISH , $key, $text, MCRYPT_MODE_ECB, $iv);
echo "Crypted Data : ".$crypttext."
";
$base64 = base64_encode($crypttext);
echo "Encoded Data : ".$base64."
";
$decode = base64_decode($base64);
$decryptdata = mcrypt_decrypt(MCRYPT_BLOWFISH , $key, $crypttext, MCRYPT_MODE_ECB, $iv);
echo "Decoded Data : ".ereg_replace("?", null , $decryptdata);
//event if i add '?' to the sting to the text it works, I don't know why.
Please note that it is just a concept. Any improvement on this code would be highly appreciable.