- Open a terminal window.
- Type the following command and press Enter:
sudo apt-get update
- Type the following command and press Enter:
sudo apt-get install gnupg
- Open Terminal app.
- Install Homebrew (if it's not already installed) by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Type the following command and press Enter:
brew install gnupg
pecl install gnupg
- If you got error retry to install
brew reinstall gpgme
- install
brew install gnupg
- Download the Gpg4win installer from the official website:
https://gpg4win.org/
- Run the installer and follow the instructions to install Gpg4win.
- Once the installation is complete, you should be able to use GnuPG.
After installation, you can test whether GnuPG is installed correctly by running the following command in the terminal or command prompt:
gpg --version
First, you need to generate a public-private key pair. This can be done using a command-line tool like GPG. Here's how to do it: Go to above project folder and open it in VS code. open Terminal and follow below steps.
-
Generate a new key pair by running the following command:
gpg --gen-key
-
Follow the prompts to configure your key. You'll be asked to enter a name, an email address, and a passphrase.
gpg --armor --output public.key --export your@email.com
Once your key has been generated, you can export your public key to a file:
-
You can also export your private key to a file, but be sure to keep it in a safe place:
gpg --armor --output private.key --export-secret-key your@email.com
- Open a terminal or command prompt on your computer.
- Type
gpg --list-keys
and press Enter. This will list all the keys in your keyring, including the public keys of others and your own public and private keys. - Scroll through the output and locate the key you want to use for encryption.
- Note down the ID of the key, which is a string of letters and numbers that comes after the slash (/) in the output. For example, if the key ID is "12345678", you would note down "12345678".
- Put above noted key id to the code for encyption
$gpg->addencryptkey('YOUR_KEYRING_ID_HERE');
- For decryption put key ID in
$gpg->adddecryptkey("YOUR_KEYRING_ID_HERE","PASSPHRASE")
gpg --import private.key
Add extension to php.ini file
extension=gnupg