Add key generation examples
This commit is contained in:
parent
e03fe86077
commit
8f830e09ac
1 changed files with 19 additions and 0 deletions
19
README.md
19
README.md
|
|
@ -45,6 +45,25 @@ If you use build.sh, you may need to modify the paths in it.
|
|||
### Encrypt and decrypt
|
||||
|
||||
### Generate key
|
||||
Keys are generated with the `GenerateKey` function, that returns the armored key as a string and a potential error.
|
||||
The library supports RSA with different key lengths or Curve25519 keys.
|
||||
```
|
||||
var pmCrypto = PmCrypto{}
|
||||
|
||||
var (
|
||||
localPart = "name.surname"
|
||||
domain = "example.com"
|
||||
passphrase = "LongSecret"
|
||||
rsaBits = 2048
|
||||
ecBits = 256
|
||||
)
|
||||
|
||||
// RSA
|
||||
rsaKey, err := pmCrypto.GenerateKey(localPart, domain, passphrase, "rsa", rsaBits)
|
||||
|
||||
// Curve 25519
|
||||
ecKey, err := pmCrypto.GenerateKey(localPart, domain, passphrase, "x25519", ecBits)
|
||||
```
|
||||
|
||||
### Sign
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue