Encrypting (large) files in PHP with openSSL

前端 未结 4 1717
再見小時候
再見小時候 2020-12-11 06:30

I\'m trying to encrypt (big) files in PHP using AES and have looked into using Mcrypt and OpenSSL, the problem is all solutions I have found so far only encrypt strings, and

4条回答
  •  臣服心动
    2020-12-11 06:53

    http://www.shellhacks.com/en/Encrypt-And-Decrypt-Files-With-A-Password-Using-OpenSSL

    $ openssl enc -aes-256-cbc -salt -in file.txt -out file.txt.enc
    

    to not use too much memory, you want a stream cipher. Call this in PHP with backticks `

    or with shell_exec

    Edit

    As shell exec is not available

    http://jeremycook.ca/2011/03/20/easy-file-encryption/

    There is a solution there. Though and I can't stress this enough. Stream ciphers are hard I have not reviewed the code there fully nor do I think I am capable. Using open SSL directly is a much better option

    http://php.net/manual/en/filters.encryption.php

    Is the example code

提交回复
热议问题