php/shell script encrypting member IDs in a mysql database
I need a way to encypt and hash 14-digit member IDs stored in a mysql database automatically, preferably directly through php, but I guess I can also call a shell script which executes the script with the supplied variables.
The member ID as well as the hash is going to be printed on a physical ID card for verification.
The script should select and encrypt all the IDs which are not already encrypted in from the field 'id' in table 'memberdata' in database 'members' with user 'user' and password 'password' on 'localhost', then write the hashes to the 'idhash' field for each respective record.
The IDs are encrypted using aes256 encryption with a supplied key and then made an md5 hash, with the following command:
$sql="SELECT * FROM memberdata";
//is id greater than 14?, (md5 hash is 32 characters)
if(!strlen($id) > 14)
echo"<br> id is :: $id";//prints out every row of the database
//as a list of md5 hashes.
You're probably getting the parse error because openssl expects its input to be supplied by the file listed in the -in parameter, or by stdin. You'll need to change your code to write the ID to a temporary file first, or to pipe it into the command.