Open In App

HTML DOM Keygen keytype Property

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:

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>
<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:


Article Tags :