我想在保存之前使用PHP函數openssl_private_encrypt()加密上傳的文件(請參閱下面的代碼片段),但是它的布爾返回false並且加密的內容返回沒有任何回報。沒有顯示或報告錯誤。openssl_private_encrypt()返回false,輸出爲0
$data = file_get_contents($_FILES['files']['tmp_name'][0]);
openssl_private_encrypt($data,$encrypted,$key);
$hash = sha1($encrypted);
file_put_contents('/path/to/folder/'.$hash,$encrypted);
有沒有人有任何想法,爲什麼這是行不通的?
感謝
你怎麼初始化$關鍵?檢查它是否正確resorurce(var_dump($ key)) – ziollek
$ key被拉爲file_get_contents('key.pem'); –