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?
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.