Update documentation (#63)

This commit is contained in:
wussler 2020-07-20 16:49:54 +02:00 committed by GitHub
parent 8c04ff64a5
commit e6a863de49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View file

@ -26,6 +26,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(key *Key) GetEntity() *openpgp.Entity
```
- Helpers for binary message encryption and decryption
```go
EncryptBinaryMessageArmored(key string, data []byte) (string, error)
DecryptBinaryMessageArmored(privateKey string, passphrase []byte, ciphertext string) ([]byte, error)
```
### Changed
- Improved key and message armoring testing
- `EncryptSessionKey` now creates encrypted key packets for each valid encryption key in the provided keyring.
@ -33,7 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Public key armoring headers
- `EncryptSessionKey` throws an error when invalid encryption keys are provided
- Session keys' size is now checked against the expected value to prevent panics
## [2.0.1] - 2020-05-01
### Security
- Updated underlying crypto library

View file

@ -151,13 +151,13 @@ const passphrase = []byte(`the passphrase of the private key`) // Passphrase of
// encrypt plain text message using public key
armor, err := helper.EncryptMessageArmored(pubkey, "plain text")
// decrypt armored encrypted message using the private key and obtain plain text
decrypted, err := helper.DecryptMessageArmored(privkey, passphrase, armor)
// encrypt binary message using public key
armor, err := helper.EncryptBinaryMessageArmored(pubkey, []byte("plain text"))
// decrypt armored encrypted message using the private key and got plain text
decrypted, err := helper.DecryptMessageArmored(privkey, passphrase, armor)
// decrypt armored encrypted message using the private key and got binary
// decrypt armored encrypted message using the private key expecting binary data
decrypted, err := helper.DecryptBinaryMessageArmored(privkey, passphrase, armor)
```
@ -173,7 +173,7 @@ armor, err := helper.EncryptSignMessageArmored(pubkey, privkey, passphrase, "pla
decrypted, err := helper.DecryptVerifyMessageArmored(pubkey, privkey, passphrase, armor)
```
With binary data or advanced modes:
For more advanced modes the full API (i.e. without helpers) can be used:
```go
// Keys initialization as before (omitted)
var binMessage = crypto.NewPlainMessage(data)