Skip to content
Related Articles

Related Articles

Improve Article

HTML DOM window crypto property

  • Last Updated : 16 Jul, 2020

The Window.crypto property returns the crypto object associated with the global object. This is a read-only property. This object allows web pages to access certain cryptographic related services. This crypto object offers some methods to access, exp getRandomValues() method.


Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

var cryp = window.crypto or window.msCrypto;

Value: This property returns an instance of the crypto object.

Example: This example uses the crypto property with its getRandomValues() method to generate a random array of size 5.

    <title>window crypto property</title>
<body style="text-align:center;">
    <h1 style="color:green;">  
    HTML | Window.crypto property
    <button onclick = "Geeks();">
    click here
    <p id="arr"
        var arr = document.getElementById("arr");
        function Geeks() {
            var array = new Uint16Array(5);
            a = window.crypto.getRandomValues(array);
            arr.innerHTML = "The random array is: "+a;


Before Clicking Button:

After Clicking Button:

Also, the crypto object in the console is:

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

My Personal Notes arrow_drop_up
Recommended Articles
Page :