Update documentation (#63)
This commit is contained in:
parent
8c04ff64a5
commit
e6a863de49
2 changed files with 14 additions and 6 deletions
|
|
@ -26,6 +26,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
(key *Key) GetEntity() *openpgp.Entity
|
(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
|
### Changed
|
||||||
- Improved key and message armoring testing
|
- Improved key and message armoring testing
|
||||||
- `EncryptSessionKey` now creates encrypted key packets for each valid encryption key in the provided keyring.
|
- `EncryptSessionKey` now creates encrypted key packets for each valid encryption key in the provided keyring.
|
||||||
|
|
@ -33,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Public key armoring headers
|
- 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
|
## [2.0.1] - 2020-05-01
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -151,13 +151,13 @@ const passphrase = []byte(`the passphrase of the private key`) // Passphrase of
|
||||||
// encrypt plain text message using public key
|
// encrypt plain text message using public key
|
||||||
armor, err := helper.EncryptMessageArmored(pubkey, "plain text")
|
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
|
// encrypt binary message using public key
|
||||||
armor, err := helper.EncryptBinaryMessageArmored(pubkey, []byte("plain text"))
|
armor, err := helper.EncryptBinaryMessageArmored(pubkey, []byte("plain text"))
|
||||||
|
|
||||||
// decrypt armored encrypted message using the private key and got plain text
|
// decrypt armored encrypted message using the private key expecting binary data
|
||||||
decrypted, err := helper.DecryptMessageArmored(privkey, passphrase, armor)
|
|
||||||
|
|
||||||
// decrypt armored encrypted message using the private key and got binary
|
|
||||||
decrypted, err := helper.DecryptBinaryMessageArmored(privkey, passphrase, armor)
|
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)
|
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
|
```go
|
||||||
// Keys initialization as before (omitted)
|
// Keys initialization as before (omitted)
|
||||||
var binMessage = crypto.NewPlainMessage(data)
|
var binMessage = crypto.NewPlainMessage(data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue