https://github.com/evotecit/pspgp
PSPGP is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.
https://github.com/evotecit/pspgp
gpg pgp powershell
Last synced: 6 months ago
JSON representation
PSPGP is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.
- Host: GitHub
- URL: https://github.com/evotecit/pspgp
- Owner: EvotecIT
- License: mit
- Created: 2021-05-08T15:53:53.000Z (over 4 years ago)
- Default Branch: v2-speedygonzales
- Last Pushed: 2025-07-16T13:52:03.000Z (6 months ago)
- Last Synced: 2025-08-08T09:44:30.200Z (6 months ago)
- Topics: gpg, pgp, powershell
- Language: C#
- Homepage:
- Size: 6.12 MB
- Stars: 65
- Watchers: 4
- Forks: 22
- Open Issues: 3
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.MD
- Funding: .github/FUNDING.yml
- License: License
Awesome Lists containing this project
README
# PSPGP - PowerShell Module
**PSPGP** is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.
**PSPGP** uses the following .NET library:
- [PgpCore](https://github.com/mattosaurus/PgpCore) - licensed MIT
## To install
```powershell
Install-Module -Name PSPGP -AllowClobber -Force
```
Force and AllowClobber aren't necessary, but they do skip errors in case some appear.
## And to update
```powershell
Update-Module -Name PSPGP
```
That's it. Whenever there's a new version, you run the command, and you can enjoy it. Remember that you may need to close, reopen PowerShell session if you have already used module before updating it.
**The essential thing** is if something works for you on production, keep using it till you test the new version on a test computer. I do changes that may not be big, but big enough that auto-update may break your code. For example, a small rename to a parameter, and your code stops working! Be responsible!
## IMPORTANT
This module works correctly on Windows/Linux and MacOS, but since it uses **.NET STANDARD 2.0** library it requires minimum of **.NET Framework 4.7.2** installed on a Windows machine when using PowerShell 5.1. Please make sure to keep your .NET Framework up to date on **Windows Client/Servers**.
## Using
### Create new PGP Public/Private Keys
```powershell
New-PGPKey -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc -FilePathPrivate $PSScriptRoot\Keys\PrivatePGP.asc -UserName 'przemyslaw.klys' -Password 'ZielonaMila9!'
```
### Encrypt Folder
```powershell
Protect-PGP -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc -FolderPath $PSScriptRoot\Test -OutputFolderPath $PSScriptRoot\Encoded
```
### Decrypt Folder
```powershell
Unprotect-PGP -FilePathPrivate $PSScriptRoot\Keys\PrivatePGP.asc -Password 'ZielonaMila9!' -FolderPath $PSScriptRoot\Encoded -OutputFolderPath $PSScriptRoot\Decoded
```
Decrypting can also be done using multiple private keys:
```powershell
Unprotect-PGP -FilePathPrivate $PSScriptRoot\Keys\PrivatePGP.asc,$PSScriptRoot\Keys\PrivatePGP1.asc -Password 'ZielonaMila9!' -String $ProtectedString
```
### Encrypt / Decrypt String
```powershell
$ProtectedString = Protect-PGP -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc -String "This is string to encrypt"
Unprotect-PGP -FilePathPrivate $PSScriptRoot\Keys\PrivatePGP.asc -Password 'ZielonaMila9!' -String $ProtectedString
```
### Verify signature
```powershell
$ProtectedString = Protect-PGP -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc -String "This is string to encrypt"
# Verify using one or more public keys
Test-PGP -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc,$PSScriptRoot\Keys\Other.asc -String $ProtectedString
Test-PGP -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc,$PSScriptRoot\Keys\Other.asc -FolderPath $PSScriptRoot\Encoded
```
### Sign string
```powershell
$Signature = Protect-PGP -SignOnly -SignKey $PSScriptRoot\Keys\PrivatePGP.asc -SignPassword 'ZielonaMila9!' -String 'Signed text'
Test-PGP -FilePathPublic $PSScriptRoot\Keys\PublicPGP.asc -String $Signature
```