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. 

Syntax:

It returns a keytype property.

keygenObject.keytype

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. 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <style>
        h1 {
            color: green;
        }
  
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML DOM Keygen keytype Property</h2>
    <br>
  
    <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">
    </form>
  
    <button onclick="display()">Display</button>
    <button onclick="set_name()">Set</button>
  
    <p id="test"></p>
  
    <script>
        function display() {
            var d = document.getElementById("keygenID").keytype;
            alert(
                "The value of the keytype is !" + d
            );
        }
        function set_name() {
            var g = document.getElementById("keygenID")
                    .keytype = "dsa";
                      
            alert(
                "The  value of the Keytype "
                + "attribute was changed to " + g
            );
        }
    </script>
</body>
  
</html>

Output:            

Supported Browsers:

  • Google Chrome
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!