--- title: Window.crypto slug: Web/API/crypto_property tags: - API - HTML DOM - Janela - NeedsCompatTable - Propriedade - Referencia - Window translation_of: Web/API/Window/crypto original_slug: Web/API/Window/crypto ---
{{domxref("Window.crypto")}} propriedade somente de leitura, devolve um objeto do tipo {{domxref("Crypto")}} associado ao objeto global. Este objeto permite que páginas da web utilizem recursos de criptografia.
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
genRandomNumbers = function getRandomNumbers() { var array = new Uint32Array(10); window.crypto.getRandomValues(array); var randText = document.getElementById("myRandText"); randText.innerHTML = "The random numbers are: " for (var i = 0; i < array.length; i++) { randText.innerHTML += array[i] + " "; } }
<p id="myRandText">The random numbers are: </p> <button type="button" onClick='genRandomNumbers()'>Generate 10 random numbers</button>
{{ EmbedLiveSample('Example') }}
Especificação | Status | Comentário |
---|---|---|
{{SpecName("Web Crypto API", "#dfn-GlobalCrypto", "Window.crypto")}} | {{Spec2("Web Crypto API")}} | Definição inicial. |
{{CompatibilityTable}}
Característica | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Edge | Opera | Safari |
---|---|---|---|---|---|---|---|
Suporte básico | 44 {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | 11 {{property_prefix("ms")}} | 20 | 19 | {{CompatVersionUnknown}} |
Característica | Chrome for Android | Edge | Firefox Mobile | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Suporte básico | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |