Computer >> Computer tutorials >  >> Programming >> HTML

How to use the <keygen> tag in HTML?


The HTML <keygen> tag is to process web forms with certificate management systems. On form submission, the private key gets stored locally and submits the public key to the server.

Here are the attributes of the <keygen> tag −

Attribute
Value
Description
autofocusHow to use the <keygen> tag in HTML?autofocus
Specifies that when the page loads the <keygen> element automatically gets focus.
challengeHow to use the <keygen> tag in HTML?challenge
Specifies the challenge string to be packaged with the public key in the PublicKeyAndChallenge for use in verification of the form submission. If no challenge string is provided, then it is encoded as an IA5STRING of length zero.
disabledHow to use the <keygen> tag in HTML?disabled
Specifies that <keygen> element should be disabled.
formHow to use the <keygen> tag in HTML?form_id
Specifies one or more forms.
How to use the <keygen> tag in HTML?keytype
rsa
dsa
ec
Specifies the secret algorithm which is the key.
nameHow to use the <keygen> tag in HTML?autofocus
Specifies a name.


How to use the <keygen> tag in HTML?

Example

You can try to run the following code to learn about the usage of <keygen> tag in HTML −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML keygen Tag</title>
   </head>
   <body>
      <form>
         <keygen name = "random_key" challenge = "0987655421">
         <input name = "sname" value = "Student Name">
      </form>
   </body>
</html>