Home>Article>Backend Development> How to encrypt files using gpg via php
Encryption A simple yet practical task is to send encrypted email. For years, the standard for encrypting email has been PGP. But it is commercial software and cannot be used freely. As an alternative to PGP, an open source similar product is now available. GPG does not contain patented algorithms and can be used for commercial applications without restrictions.
#Background: The customer provides the private key and requires us to transfer the encrypted file to them through php.
macOS Sierra 10.12.1
php 7.0.8
$ brew install gpg
$ yum install gnupg
Install gnupg extension, please refer to my old article for specific methods: Use phpize to install the php extension
$ gpg --import /Users/xjnotxj/downloads/6e.pri
$ gpg --recipient 0D39xxxx --output test_file.xls.gpg --encrypt test_file.xls
0D39xxxx => #1
$ gpg -o test_file_new.xls -d test_file.xls.gpg
$ gpg -o pubkey.txt -a --export e6e6xxxx
e6e6xxxx => #
The above is the detailed content of How to encrypt files using gpg via php. For more information, please follow other related articles on the PHP Chinese website!