Create an encrypted zip archive with PHP

后端 未结 5 1439
闹比i
闹比i 2020-11-29 05:05

I am searching for a way to encrypt a .txt file into a zip, but in a secure password protected way. My goal is to email this file to me, without anyone being able to read th

5条回答
  •  孤城傲影
    2020-11-29 05:54

    This is how I did it. It's with an excel, but it's the same thing.

    • Let php create a random codename.
    • Save the codename in db or in a file to be included by the retrieve.php.
    • Mail yourself the codename.

    • Access via web the retrieve.php?codename=[codename]

    • Let php check if codename is correct. (maybe even it's age).
    • Create the excel/textfile in memory from the data that needs to be send to you.
    • Create an encryption code by adding a local password (that only you know) with the codename.( I say add but can also be mixed or xor-ed or substr... )
    • Encrypt on the fly with the created encryption code.
    • Remove the codename from db or config file.
    • Return this encrypted document in a mail (zipped or not for size).
    • Maybe add two first characters from codename in the mail to know what local full codename to use.

    • Use a local decryption script to decode the downloaded file. Use same codename/password algorithm to create a decryption key.

    I use gibberish-aes-php. ( https://github.com/ivantcholakov/gibberish-aes-php )
    Because then I can use https://github.com/mdp/gibberish-aes as javascript on a client decoder (for things I want to take a quick peek at in a browser).

提交回复
热议问题