Enchantrix/examples/pgp_generate_keys/main.go

30 lines
845 B
Go

// Example: PGP key pair generation
//
// This example demonstrates generating an OpenPGP key pair with
// name, email, and comment metadata. The output is ASCII-armored
// for easy storage and distribution.
//
// Run with: go run examples/pgp_generate_keys/main.go
package main
import (
"fmt"
"log"
"github.com/Snider/Enchantrix/pkg/crypt"
)
func main() {
fmt.Println("--- PGP Key Generation Demo ---")
cryptService := crypt.NewService()
// 1. Generate PGP key pair
fmt.Println("Generating PGP key pair...")
publicKey, privateKey, err := cryptService.GeneratePGPKeyPair("test", "test@example.com", "test key")
if err != nil {
log.Fatalf("Failed to generate PGP key pair: %v", err)
}
fmt.Println("Key pair generated successfully.")
fmt.Printf("\nPublic Key:\n%s\n", publicKey)
fmt.Printf("\nPrivate Key:\n%s\n", privateKey)
}