It really depends on how sensitive the data is. However, from my experience, simple php encryption usually does the trick. I usually encrypted sensitive fields in json data fields before encoding them in a json string.
Here is the code for the encryption part.
$ key = 'password for (en / de) crypt'; $ string = 'string for encryption'; // mark spaces
Encrypt:
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
To decrypt:
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
However, you should always use hash (MD5, SHA1) passwords, preferably with some salt.
iewnait
source share