NewEncrypter returns a new encrypter with initialized keypair
(privateKey, publicKey string)
| 46 | |
| 47 | // NewEncrypter returns a new encrypter with initialized keypair |
| 48 | func NewEncrypter(privateKey, publicKey string) (*Encrypter, error) { |
| 49 | e := &Encrypter{} |
| 50 | pubKey, key, err := e.fetchOrGenerateKeys(privateKey, publicKey) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | e.privateKey, e.publicKey = key, pubKey |
| 55 | return e, nil |
| 56 | } |
| 57 | |
| 58 | // PublicKey returns a base64 encoded public key. Useful for transport (like in HTTP requests) |
| 59 | func (e *Encrypter) PublicKey() string { |
no test coverage detected