// Two-way encryption example using the MySQL AES_DECRYPT() function. // Store the salt variable securely in a related include file. // Or initiate using .htaccess which is unlikely to ba accessible: // SetEnv MY_SALT abcdef123 // The above in .htaccess should produce global $_SERVER['MY_SALT'] // Otherwise set your salt in a single file which is included by all phpMyEdit forms. $salt = 'abcdef123'; // $_SESSION['sess_user_level'] is a variable used to suppress the display // of the `my_password` field unless the logged-in user has a user level of 9. if($_SESSION['sess_user_level'] == 9){ $opts['fdd']['my_password'] = array( 'default' => '', 'name' => 'My Password', 'options' => 'ACPVD', 'sort' => false, 'sql|ACPVD' => 'if(my_password <> "", AES_DECRYPT(my_password, "'.$salt.'"), "")', 'sqlw' => 'AES_ENCRYPT(TRIM("$val_as"), "'.$salt.'")' ); // MySQL column type `my_password` is tinyblob } ################################################################################ // One way encryption with MySQL's MD5() function. if($_SESSION['sess_user_level'] == 9){ $opts['fdd']['user_pass'] = array( 'default' => '', 'input' => 'W', 'maxlen' => 60, 'name' => 'User Pass', 'options' => 'ACPVD', 'required' => true, 'select' => 'T', 'size|ACP' => 60, 'sqlw' => 'IF(user_pass = $val_qas, $val_qas, MD5($val_qas))', 'sort' => $sort ); // MySQL column type varchar(60) } ################################################################################