<keygen>


HTML <keygen> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

<form action="demo_keygen.php" method="get">
  用户名: <input type="text" name="usr_name">
  加密: <keygen name="security">
  <input type="submit">
</form>

<p><strong>注意:</strong> Internet Explorer 不支持 keygen 标签。</p>

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

Firefox, Opera, Chrome and Safari 6 All support the <keygen> tag.


Tag definition and usage instructions

<keygen> The tag specifies the key pair generator field used in the form.

When the form is submitted, the private key is stored locally and the public key is sent to the server.


Differences between HTML 4.01 and HTML5

The<keygen> element is the HTML5 new tag.


Attributes

New: HTML5 new attributes.

PropertiesValueDescription
autofocusNew autofocus Causes the <keygen> field to gain focus when the page loads.
challengeNewchallengeIf used, sets the value of keygen to ask on commit.
disabledNewdisabledDisables the <keygen> element field.
formNewform_idDefine an or Multiple forms.
keytypeNewrsa
dsa
ec
defines the security algorithm of the key.
nameNewnamedefines the unique name of the <keygen> element. The name attribute is used to collect the value of the field when submitting the form.
##Global attributes

<keygen> tag supports global attributes, view the complete attribute table HTML global attributes.


Events Attribute

<keygen> tag supports all HTML event attributes.