Open In App

How to set the security algorithm of key in HTML5 ?

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will see how to set the security algorithm of keys using HTML5. To set the security algorithm of key <keygen> tag is used. This tag specifies a key-pair generator field used for forms. The private key is saved locally and the public key is sent to the server when the form is sent. The element’s aim is to provide a safe method of user authentication. When a form is submitted, two keys, a private key, and a public key, are produced. The public key is sent to the server, while the private key is kept locally. The public key is used to build a client certificate that can be used to validate the user’s identity in the future.

Syntax:

<keygen name = "name">

Example: In this example, we are using <keygen> tag for specifying the security algorithm.

HTML




<!DOCTYPE html>
<html>
<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>
        Specifying the security algorithm
        of the key in HTML5
      </h2>
    <form>
        Username: <input type="text" name="name">
        <br><br> Encryption: <keygen name="key">
        <input type="submit">
    </form>
</body>
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Firefox
  • Opera
  • Apple Safari

Last Updated : 02 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads