DEV Community

Share Point Anchor
Share Point Anchor

Posted on • Originally published at sharepointanchor.com on

HTML <keygen> Keygen Tag

In HTML, the Keygen tag is used to generate an encryption key for passing the encrypted data to a server. It is one of the new sectioning elements in HTML 5. The main purpose of the element is to provide a secure way to authenticate users.

When an HTML < form> is submitted, the browser will generate two keys. One is a private key and another one is a public key. The private key 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 future purposes.

Estimated reading time: 3 minutes

Syntax:

The tag doesn’t require the closing tag in HTML. But in XHTML it contains both the opening tag and closing tag.


<keygen name= "name">

Enter fullscreen mode Exit fullscreen mode

HTML Tag Characteristics:

th, td{ padding: 20px; }

| HTML tag | This tag specifies a key-pair generator field used for forms |
| Content categories | Flow content, Phrasing content, interactive content, listed, labelable, submittable, resettable form-associated element, palpable content. |
| Permitted content | None. It is an empty element. |
| Tag omission | Must have a start tag and end tag is not required. |
| Permitted parents | Any HTML element that accepts phrasing content. |
| Permitted ARIA roles | None |
| DOM interface | HTMLKeygenElement |

Sample of the HTML Tag:


<!DOCTYPE html>
<html>
  <head>
    <title>HTML <keygen> Tag</title>
  </head>
  <body>
<h2>Example of the HTML <keygen> Tag</h2>
    <form action="/form/submit" method="get">
      <keygen name="rsaPublicKey" keytype="RSA">
        User Name:
        <input type="text" name="usr_name">
        <input type="submit">
    </form>
  </body>
</html>

Enter fullscreen mode Exit fullscreen mode

Note : The functionality of the element in HTML depended on the web browser and the corresponding web server program.

Result:

Result

Download Sample File:

HTML-keygen-tagDownload

Attributes:

The HTML keygen tag supports both the Global Attributes and Event Attributes.

th, td{ padding: 20px; }

Attribute Value Description
autofocus autofocus This attribute is used to define the loading of the page the element must automatically receive a focus. Not supported in Internet Explorer and Firefox.
challenge challenge It defines the call string , that is passed along with the public key. The attribute value is any text string. If the attribute isn’t specified, the default is an empty string.
disabled disabled This indicates that the element must be disabled.
form form_id The form element will help to indicate the identifier of the form or forms to which the element belongs. Not supported in Internet Explorer.
keytype It defines the key-encryption algorithm.
rsa From the key type attribute, the user can choose between high and medium security (the default value).
dsa Used to select the key size.
ec The user can choose between high and medium security. Not supported in Internet Explorer and Safari.
name name Helps to define the name of the element.

Browser Support:

Result

Related Articles:

The post HTML Keygen Tag appeared first on Share Point Anchor.

Top comments (0)