Reputation: 139
How to generate a public/private key pair in the user's browser,
This key must be:
I tried using <keygen>
but it requires using forms and user intervention.
Upvotes: 3
Views: 659
Reputation: 10695
Consider using WebCrypto
Specifically, crypto.subtle.generateKey
will do the key generation.
The key can be temporary as long as you discard it securely and/or invalidate it after its desired validity period has expired. Depending on how your system works, you may want to validate the expiry/validity of a given key by rolling it into the hash.
Here is a tutorial which offers a cross-browser solution.
Hashing the key (and/or other data) can be done using other parts of the WebCrypto API (see crypto.subtle.digest
)
Upvotes: 2