Fetch HTML 5 Keygen Tag Value – ASP.Net


Fetch HTML 5 Keygen Tag Value – ASP.Net


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.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<form action="Default.aspx" method="post">
 User Name:
 <input type="text" name="username" />
 <keygen keytype="rsa" name="security" />
 <input type="submit" value="Submit" />

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.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
 protected void Page_Load(object sender, EventArgs e)
 string userName = Request["username"].ToString();
 string key = Request["security"].ToString();
 lblKey.Text = "Username = " + userName + " and Key = " + key;


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




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

Share This Post

Related Articles

Powered by Paras Babbar · Designed by Paras Babbar