Good morning, for passwords I always use a hash sha1
or something that has no return, always merge with a key of its own as date or a text or something that varies from client to client.
To encrypt user information I advise you to generate a key for each user, it can be an md5 of a timestamp NOW() that serves. then you have a key your q no one has access that one way or another you use it along with the client key and encrypt his data passing through a crypt or a Base64 using this key.
Once this is done, whoever picks up db will already have a huge difficulty discovering its key to see the contents of the generated hashs.
The guy would have to hack into your system and see in hardcode the generated key.
---- I’ll give an ex using php ----
to generate the key for each user
$key=md5($nomedousuario.$email.date('Ymd'));
what has been done up there is to generate a single key for this user
Prox step you have to have a key your or more of a key like I do but in case I will only exemplify with 1 for you to understand the process.
$minhakey="87ye7jn789heyn986db87b";
I generated a random key that you can treat her however you want.
in my case I do the following
$key_completa = str_replace("7"," ",$key.$minhakey);
what has been done is to remove the number 7 ( for freshness ) and generate a unique key that nobody knows exists, this is the secret of the thing vc has q have a key q vc know how it was generated to encrypt all information so that there is a way to read it.
To encrypt the content you do the following now, let’s assume that I have the customer email and want to protect , will stay like this, Obs. use these functions I’m going through to facilitate the process.
function encrypt($data, $key){
return base64_encode(
mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
$key,
$data,
MCRYPT_MODE_CBC,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
)
);
}
function decrypt($data, $key){
$decode = base64_decode($data);
return mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
$key,
$decode,
MCRYPT_MODE_CBC,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
);
}
to encode
$email_protegido=encrypt("[email protected]",$key_completa);
to decode
$email_legivel=decrypt($email_protegido,$key_completa);
to increase security go can hide the code that generates the key doing so.
you will transform the whole function into a base 64
echo base64_encode('$key_completa = str_replace("7"," ",$key.$minhakey);');
will return it here
JGtleV9jb21wbGV0YSA9IHN0cl9yZXBsYWNlKCI3IiwiICIsJGtleS4kbWluaGFrZXkpOw==
then just do so to run
eval(base64_decode('JGtleV9jb21wbGV0YSA9IHN0cl9yZXBsYWNlKCI3IiwiICIsJGtleS4kbWluaGFrZXkpOw=='));
so the guy who has a cess to Cod will have a hard time finding out what the q is.
of course you can use a zend to encrypt all your php increasing security
I found a lot of questions for just one question.
– Marco Souza
Did any of the answers solve your problem? Do you think you can accept one of them? If you haven’t already, see [tour] how to do this. You would help the community by identifying the best solution for you. You can only accept one of them, but you can vote for any question or answer you find useful on the entire site.
– Maniero