From 8f830e09ac2ed4c85fb01073ffaaed6bbf3f8328 Mon Sep 17 00:00:00 2001 From: Aron Wussler Date: Tue, 14 May 2019 10:54:27 +0200 Subject: [PATCH] Add key generation examples --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 2459b35..b29a00d 100644 --- a/README.md +++ b/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