diff options
author | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:36:08 +0100 |
---|---|---|
committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:36:08 +0100 |
commit | 39f2114f9797eb51994966c6bb8ff1814c9a4da8 (patch) | |
tree | 66dbd9c921f56e440f8816ed29ac23682a1ac4ef /files/fr/web/api/crypto | |
parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
download | translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.gz translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.bz2 translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.zip |
unslug fr: move
Diffstat (limited to 'files/fr/web/api/crypto')
-rw-r--r-- | files/fr/web/api/crypto/getrandomvalues/index.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/files/fr/web/api/crypto/getrandomvalues/index.html b/files/fr/web/api/crypto/getrandomvalues/index.html new file mode 100644 index 0000000000..28682a0c2a --- /dev/null +++ b/files/fr/web/api/crypto/getrandomvalues/index.html @@ -0,0 +1,75 @@ +--- +title: RandomSource.getRandomValues() +slug: Web/API/RandomSource/getRandomValues +tags: + - API + - Cryptographie + - Methode(2) + - Méthode + - Reference + - Référence(2) +translation_of: Web/API/Crypto/getRandomValues +--- +<p>{{APIRef("Web Crypto API")}}</p> + +<p>La méthode <code><strong>RandomSource.getRandomValues()</strong></code> permet d’obtenir des valeurs pseudo-aléatoires cryptographiquement satisfaisantes. Le tableau donné en paramètre est rempli avec des nombres pseudo-aléatoires.</p> + +<p>Pour garantir une performance suffisante, les implémentations n’utilisent pas un vrai générateur de nombres aléatoires, mais un générateur de nombres pseudo-aléatoires <em>semé </em>avec une valeur ayant suffisamment d'{{Glossary("entropie")}}. Les générateurs utilisés d’une implémentation à une autre seront différents mais toujours satisfaisants pour une utilisation en cryptographie. Les implémentations doivent également utiliser une graine ayant suffisamment d’entropie, comme une source d’entropie au niveau du système.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox"><em>cryptoObj</em>.getRandomValues(<em>typedArray</em>);</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><em>typedArray</em></dt> + <dd>Un {{jsxref("TypedArray")}} de nombres entiers, qui est un {{jsxref("Int8Array")}}, un {{jsxref("Uint8Array")}}, un {{jsxref("Uint16Array")}}, un {{jsxref("Int32Array")}}, ou encore un {{jsxref("Uint32Array")}}. Tous les éléments du tableau seront subsitués avec des nombres aléatoires.</dd> +</dl> + +<h3 id="Exceptions">Exceptions</h3> + +<ul> + <li>Une {{exception("QuotaExceededError")}} {{domxref("DOMException")}} est levée si la taille de la requête est plus grand que 65 536 octets.</li> +</ul> + +<h2 id="Exemple">Exemple</h2> + +<pre class="brush: js">/* on part du principe ici que window.crypto.getRandomValues est disponible */ + +var array = new Uint32Array(10); +window.crypto.getRandomValues(array); + +console.log("Your lucky numbers:"); +for (var i = 0; i < array.length; i++) { + console.log(array[i]); +} +</pre> + +<h2 id="Specification" name="Specification">Spécification</h2> + +<table class="spec-table standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('Web Crypto API', '#RandomSource-method-getRandomValues')}}</td> + <td>{{Spec2('Web Crypto API')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<div id="compat-mobile">{{Compat("api.Crypto.getRandomValues")}}</div> + +<h2 id="Voir_aussi">Voir aussi</h2> + +<ul> + <li>{{ domxref("Window.crypto") }} pour obtenir un objet {{domxref("Crypto")}}.</li> + <li>{{jsxref("Math.random")}}, une source non cryptographique de nombres aléatoires.</li> +</ul> |