The HTML <keygen> element can help generate a key material as part of an HTML form and submit the public key. This mechanism is intended for use with certificate systems based on the web. The <keygen> element is expected to be used in an HTML form along with additional information necessary to build a certificate request, and a signed certificate will be the result of the process.
Syntax: The syntax of <keygen> tag is
<keygen name="name">
Example 1: In this example, we will use <keygen> tag
HTML
<!DOCTYPE html>
< html >
< head >
< title >GFG</ title >
</ head >
< body >
< form action = "/gfg" method = "post" >
< label >Username: < input type = "text" name = "uname" ></ label >
< label >Encryption: < keygen name = "lock" ></ label >
< input type = "submit" value = "Submit" >
</ form >
</ body >
</ html >
|
Output:

keygen
Example 2: In this example, we will generate a key from <keygen> tag
HTML
<!DOCTYPE html>
< html >
< head >
< title >GFG</ title >
</ head >
< body >
< form >
< keygen name = "key" challenge = "000" >
< input name = "name" value = "Name" >
</ form >
</ body >
</ html >
|
Output:

keygen challenge
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
16 Jun, 2023
Like Article
Save Article