<?php
// the message you want to sign so that recipient can be sure it was you that
// sent it
$data = <<<EODYou have my authorization to spend $10,000 on dinner expenses.The CEO
EOD;
// save message to file
$fp = fopen("msg.txt", "w");
fwrite($fp, $data);
fclose($fp);
// encrypt it
if (openssl_pkcs7_sign("msg.txt", "signed.txt", "mycert.pem",
    array("file://mycert.pem", "mypassphrase"),
    array("To" => "[email protected]", // keyed syntax
          "From: HQ <[email protected]>", // indexed syntax
          "Subject" => "Eyes only")
    )) {
    // message signed - send it!
    exec(ini_get("sendmail_path") . " < signed.txt");
}
?> 
使用该函数做签名,涉及到文件的读写,可能会牵涉到文件的高并发性,对于php有什么好的处理方法吗?
具体点就是,我只需要传递需要签名的原始数据$data,而此函数每次都要把原始数据$data保存到文件里,然后再做签名,最后把签名后产生的串保存到signed.txt里,在实际中这肯定会触发文件操作的问题,该如何解决呢?