Skip to content
Related Articles
Open in App
Not now

Related Articles

How to generate public key in HTML ?

Improve Article
Save Article
  • Last Updated : 25 Jul, 2021
Improve Article
Save Article

You can easily generate a public key using the <keygen> tag in HTML. The <keygen> element generates an encryption key for passing encrypted data to a server. The purpose of the <keygen> element is to provide a secure way to authenticate users.

Actually, when a form is submitted then two keys are generated, private key and public key. The private key is stored locally, and the public key is sent to the server. The public key is used to generate a client certificate to authenticate the user for the future.


<keygen name="name" challenge="challenge" 
    keytype="type" keyparams="pqg-params">

Attributes Value:

  • name: Specify a name for the keygen element, which is submitted with the form data.
  • keytype:   Specify what type of key is to be generated. Values are “RSA”, “DSA” and “EC” and “RSA” is by default.
  • challenge:  A challenge string that is submitted along with the public key. Defaults to an empty string if not specified.
  • form: Specifies the <form> element that the <keygen> element is associated with.

Note: The keyparams attribute is required for DSA and EC key generation.



<!DOCTYPE html>
        <h1 style="color:green;">
        <h2>Keygen Tag</h2>
                <input type="text" name="username"></label>
                <input type="password" name="password"></label>
            <label>Encryption: <keygen name="key"></label>
            <input type="submit" value="Submit">


keygen tag

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!