Skip to content
forked from jchavannes/go-pgp

Layer on top of golang.org/x/crypto/openpgp to handle a few PGP use cases.

License

Notifications You must be signed in to change notification settings

ruben0626/go-pgp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go PGP

Layer on top of golang.org/x/crypto/openpgp to handle a few PGP use cases.

Examples

Encryption

pgp/encrypt_test.go

Encrypt

// Create public key entity
publicKeyPacket, _ := pgp.GetPublicKeyPacket([]byte(TestPublicKey))
pubEntity, _ := pgp.CreateEntityFromKeys(publicKeyPacket, nil)

// Encrypt message
encrypted, _ := pgp.Encrypt(pubEntity, []byte(TestMessage))

Decrypt

// Create private key entity
privEntity, _ := pgp.GetEntity([]byte(TestPublicKey), []byte(TestPrivateKey))

// Decrypt message
decrypted, _ := pgp.Decrypt(privEntity, encrypted)

Signing

pgp/sign_test.go

Sign

// Create private key entity
entity, _ := pgp.GetEntity([]byte(TestPublicKey), []byte(TestPrivateKey))

// Sign message
signature, _ := pgp.Sign(entity, []byte(TestMessage))

Verify

// Create public key packet
pubKeyPacket, _ := pgp.GetPublicKeyPacket([]byte(TestPublicKey))

// Verify signature
err = pgp.Verify(pubKeyPacket, []byte(TestMessage), signature)
if err == nil {
    fmt.Println("Signature verified.")
}

About

Layer on top of golang.org/x/crypto/openpgp to handle a few PGP use cases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%