Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this script does the encryption:
- function encrypt($stringArray, $key) {
- $s = strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), serialize($stringArray), MCRYPT_MODE_CBC, md5(md5($key)))), '+/=', '-_,');
- return $s;
- }
- // This sets the variables writing to the database:
- $key = "key here";
- $connect = mysql_connect("db credentials");
- $db = mysql_select_db("dbname");
- $fullname = encrypt(mysql_real_escape_string($_POST["fullname"]));
- $surname = encrypt(mysql_real_escape_string($_POST["surname"]));
- $telephone = encrypt(mysql_real_escape_string($_POST["telephone"]));
- $email = encrypt(mysql_real_escape_string($_POST["email"]));
- // This calls it from the database (obviously with the key as above)
- function decrypt($stringArray, $key) {
- $s = unserialize(rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode(strtr($stringArray, '-_,', '+/=')), MCRYPT_MODE_CBC, md5(md5($key))), "\0"));
- return $s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement