Project

PSPGP

PSPGP is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.

Stars72
Forks23
Open issues1
PowerShell Gallery downloads3814786
Releasev1.0.0
Language: C# Updated: 2026-04-07T08:35:39.0000000+00:00

Curated Examples

Generate a PGP key pair

Use PSPGP to create public and private PGP key files.

This pattern is useful when a workflow needs dedicated PGP keys for encrypted file exchange.

It is adapted from the source example at Examples/Example-GeneratePGP.ps1.

When to use this pattern

  • You need a project-specific PGP key pair.
  • The public key will be shared with another party.
  • The private key and password will be stored securely outside the script.

Example

Import-Module PSPGP

$keyFolder = Join-Path $PSScriptRoot 'Keys'
New-Item -ItemType Directory -Force -Path $keyFolder | Out-Null

New-PGPKey `
    -HashAlgorithm Sha512 `
    -FilePathPublic "$keyFolder\PublicPGP.asc" `
    -FilePathPrivate "$keyFolder\PrivatePGP.asc" `
    -UserName 'automation@example.com' `
    -Password '<store-this-securely>'

What this demonstrates

  • creating a public/private key pair
  • choosing a hash algorithm
  • keeping file paths explicit for later automation steps

Source