# go-pgp **Repository Path**: jkuang/go-pgp ## Basic Information - **Project Name**: go-pgp - **Description**: Layer on top of golang.org/x/crypto/openpgp to handle a few PGP use cases. Add support pubring - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-03-15 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Go PGP Layer on top of `golang.org/x/crypto/openpgp` to handle a few PGP use cases. ## Examples ### Encryption [encrypt_test.go](encrypt_test.go) #### Encrypt ```go // Create public key entity publicKeyPacket, _ := pgp.GetPublicKeyPacket([]byte(TestPublicKey)) pubEntity, _ := pgp.CreateEntityFromKeys(publicKeyPacket, nil) // Encrypt message encrypted, _ := pgp.Encrypt(pubEntity, []byte(TestMessage)) ``` #### Decrypt ```go // Create private key entity privEntity, _ := pgp.GetEntity([]byte(TestPublicKey), []byte(TestPrivateKey)) // Decrypt message decrypted, _ := pgp.Decrypt(privEntity, encrypted) ``` ### Signing [sign_test.go](sign_test.go) #### Sign ```go // Create private key entity entity, _ := pgp.GetEntity([]byte(TestPublicKey), []byte(TestPrivateKey)) // Sign message signature, _ := pgp.Sign(entity, []byte(TestMessage)) ``` #### Verify ```go // 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.") } ```