简体   繁体   中英

Encrypting files for others

I am trying to figure out an approach for encrypting files for other users using a PHP interface, while keeping their password private from system administrators (similar to Dropbox). I basically need to store files for users, yet keep their passwords unknown. Any suggestions?

The answer depends on who puts files, who encrypts them and who collects them. In general, public-key cryptography (PKI) works better when you need to encrypt the file for somebody else. Shared-secret schemes (including password-based ones) are worse. With PKI the recipient gives you his public key and keeps the private key in secret. You encrypt the file for the recipient using his public key and only that recipient can decrypt it as the private key is needed for decryption.

You can do PKI encryption using OpenPGP technology or using X.509 certificates. In first case you need GnuPG or some PGP library for PHP. In second case you can use OpenSSL.

Use base_64 encoding with a private key.

http://php.net/manual/en/function.base64-encode.php

Check the User Contributed Codes on the page for using a custom key and salting for additional security

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM