Reputation: 43778
Do anyone know how can I encrypted a file and attachment send out in php?
Example: If I have a csv file call test.csv. Any way that I can encrypted the file then attached and send it over to someone. Also, how can I decrypt the file from the other side?
Upvotes: 1
Views: 1569
Reputation:
get the file into $file_str:
$file_string = file_get_contents("text.csv");
encrypt via mcrypt
$key = "mykey";
$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256,$key,$file_string,MCRYPT_MODE_CBC,$key);
decrypt in client's end
$file_string = mcrypt_decrypt(MCRYPT_RIJNDAEL_256,$key,$data,MCRYPT_MODE_CBC,$key);
create the file again
file_put_contents("text.csv",$file_string);
Upvotes: 1