npm package: @isomorphic-pgp/generate
Description: Generates an OpenPGP keypair
Author: William Hilton
Latest version: 0.0.2

# @isomorphic-pgp/generate

In the browser it uses `crypto.subtle.generateKey`.

In node it uses `crypto.generateKeyPair` which was added in v10.12.0.

Tip: Once you've generated a private key, use the `convertPrivateToPublic(openpgpPrivateKey)` function of the `@isomorphic-pgp/parser` library to extract a Public Key you can share.

## Usage

### `generate(options)`
```js
const { generate } = require('@isomorphic-pgp/generate')

const openpgptext = await generate({
    userid: 'User Name <email@example.com>',
    timestamp: Math.floor(Date.now() / 1000)
})

/*
// Obviously the exact text will be different every time.
openpgptext === `-----BEGIN PGP PRIVATE KEY BLOCK-----

lQcYBFv5n9cBEADKMXAIyXS7inW/ktuYo22MKYjDRkrX5ShzSqCFczE1X3I8Q7c8
BDUZt4CcB9BJsd+RpBh67ibL3vPNhsw4Dtu9Cn7CtMAJQ/j00tvmn1jK4l+DqE6R
4KszFyaqrngPbexUEQmGS88crl6qWgppRHXdHDng9yImmKRdaJjrozcwsf2bAdqK
QOspUNPkV1ugmVS7t5kuUslhhiULZs4wPTNQzUKqKyy0Q6SgS1AQ2yhT1XtliX1t
k4Uiu7RrJ7LIjuD/2THYDySZZdVJRF9kYsNQuRiIYyq3R5ZZNFxQmiCWZtpFBpw8
JhHVivYWgehXcS+LwMKMAiRdZJAm2TgvhtNivyODcTEXODFklGeJB+k3O/TZDs23
4R1RIY05Qfrfv+Mte826bsnwNPMTGuJXPB9I0nlhIQbuEQJOVR91vijYL4ofagyU
XFoVPa+cURFJwDAY9Y9stDvfcDDb63XTH2J1OPnToqcgnhcm9ZQz6LV5NB9Wxtbl
pZfFl2D/s/NGskevlVc+KZV6wceWyNpcw3O01cj7dN24m0VoN0Bqs/0r9YetoUsE
1M7n6gljxakdJUXSPXE4bjDBUm4YC27uwRxigRqlry9JXIBPrsOGNrWgPcwk33cB
Rvmj5MbZkt97ZgxaEY3l+qyi5xzMtkYWinjJ6SUmLTZ2TyoSQeMl5nZFSQARAQAB
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