Fetch HTML 5 Keygen Tag Value – PHP

Title

Fetch HTML 5 Keygen Tag Value – PHP

Introduction

The <keygen> tag specifies a key- pair generator field user for forms. When the form is submitted, the private key is stored locally and the public key is sent to the server.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="post_keygen.php" method="post">
<table>
<tr>
<th>
User Name:
</th>
<td>
 <input type="text" name="username">
</td>
</tr>
<tr>
<th>
Encryption:
</th>
<td>
 <keygen name="key" keytype="rsa">
</td>
</tr>
</table>
<input type="submit" value="Submit">
</form>
</body>
</html>

We can either use ASP.Net or PHP to capture the encryption key.

Below code will capture the key value and display on the web page.

<?php 
$userName=$_POST["username"]; 
$securityKey=$_POST["key"]; 
echo "Username = ".$userName; 
echo "key = ".$securityKey; 
?>

Note:

Keytype specifies the encryption algorithm, in this case keytype=”rsa”, i.e. RSA encryption algorithm will be used to encrypt the data.

OUTPUT

HTML_keygen_tag HTML_keygen_tag_output


JavaScript, ASP.Net & PHP Web Developer. Connect with me on Facebook and Twitter.

Share This Post

Recent Articles

Powered by Paras Babbar · Designed by Paras Babbar