Skip to content
Related Articles

Related Articles

HTML DOM Keygen keytype Property

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 05 Oct, 2021
Improve Article
Save Article

The HTML Keygen keytype property in HTML DOM is used to set or return the value of the keytype attribute of the keygen element. The keytype attribute is used to define the type of key that will be used. 


It returns a keytype property.


It is used to set the keytype property.

keygenObject.keytype = "rsa|dsa|ec"


Property values:

  • rsa: It is a default value. It defines an RSA security algorithm. It gives a  choice of RSA key strengths to the user.
  • dsa: It defines a DSA security algorithm. It gives a choice of DSA key sizes to the user.
  • ec: It defines an EC security algorithm. It gives a choice of EC key strengths to the user.

Return Values: It returns a string value that represents the type of key that is used.

Example: This example sets and returns the keytype property. 


<!DOCTYPE html>
        h1 {
            color: green;
        body {
            text-align: center;
    <h2>HTML DOM Keygen keytype Property</h2>
    <form id="formID">
        Username: <input type="text" name="uname">
        <br><br> Encryption:
        <keygen id="keygenID" form="formID" 
            name="secure" keytype="rsa" autofocus>
        <input type="submit">
    <button onclick="display()">Display</button>
    <button onclick="set_name()">Set</button>
    <p id="test"></p>
        function display() {
            var d = document.getElementById("keygenID").keytype;
                "The value of the keytype is !" + d
        function set_name() {
            var g = document.getElementById("keygenID")
                    .keytype = "dsa";
                "The  value of the Keytype "
                + "attribute was changed to " + g


Supported Browsers:

  • Google Chrome
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!