Form Element: Keygen

The purpose of the <keygen> element is to provide a secure way to authenticate users. The <keygen> element specifies a key-pair generator field in a form. When the form is submitted, two keys are generated, one private and one public. The private key is stored locally, and the public key is sent to the server. The public key could be used to generate a client certificate to authenticate the user in the future. Here is an example of a form with a keygen field:

HTML file: Displayed by browser:
<form action="http://www.w3schools.com/html/action_page.php">

Username: <input type="text" name="user">
<br />
<br />Encryption: <keygen name="security">
<br />
<br /><input type="submit">

</form>
Username:

Encryption:

I guess the username that you enter is the public key and that you never know what the private key is, but it sounds like it acts like a cookie, to recognize your device on subsequent visits to the website. Both Chrome and Firefox browsers will display the encryption choices. Unfortunately, Microsoft want keygen removed from HTML5 list, so Internet Explorer will not display the encryption choices.

Back button Table of Contents Next button