diff options
author | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:56:40 +0100 |
---|---|---|
committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:56:40 +0100 |
commit | 310fd066e91f454b990372ffa30e803cc8120975 (patch) | |
tree | d5d900deb656a5da18e0b60d00f0db73f3a2e88e /files/zh-cn/web/api/randomsource | |
parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
download | translated-content-310fd066e91f454b990372ffa30e803cc8120975.tar.gz translated-content-310fd066e91f454b990372ffa30e803cc8120975.tar.bz2 translated-content-310fd066e91f454b990372ffa30e803cc8120975.zip |
unslug zh-cn: move
Diffstat (limited to 'files/zh-cn/web/api/randomsource')
-rw-r--r-- | files/zh-cn/web/api/randomsource/getrandomvalues/index.html | 77 | ||||
-rw-r--r-- | files/zh-cn/web/api/randomsource/index.html | 107 |
2 files changed, 0 insertions, 184 deletions
diff --git a/files/zh-cn/web/api/randomsource/getrandomvalues/index.html b/files/zh-cn/web/api/randomsource/getrandomvalues/index.html deleted file mode 100644 index 5df5fb0a83..0000000000 --- a/files/zh-cn/web/api/randomsource/getrandomvalues/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Crypto.getRandomValues() -slug: Web/API/RandomSource/getRandomValues -tags: - - API - - 加密 - - 参考 - - 安全 - - 密码学 - - 方法 -translation_of: Web/API/Crypto/getRandomValues ---- -<p>{{APIRef("Web Crypto API")}}</p> - -<p><code><strong>Crypto.getRandomValues()</strong></code> 方法让你可以获取符合密码学要求的安全的随机值。传入参数的数组被随机值填充(在加密意义上的随机)。</p> - -<p>为了确保足够的性能,不使用真正的随机数生成器,但是它们正在使用具有足够熵值伪随机数生成器。它所使用的 PRNG 的实现与其他不同,但适用于加密的用途。该实现还需要使用具有足够熵的种子,如系统级熵源。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><em>cryptoObj</em>.getRandomValues(<em>typedArray</em>);</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>typedArray</code></dt> - <dd>是一个基于整数的 {{jsxref("TypedArray")}},它可以是 {{jsxref("Int8Array")}}、{{jsxref("Uint8Array")}}、{{jsxref("Int16Array")}}、 {{jsxref("Uint16Array")}}、 {{jsxref("Int32Array")}} 或者 {{jsxref("Uint32Array")}}。在数组中的所有的元素会被随机数重写。(注释:生成的随机数储存在 <code>typedArray</code> 数组上。)</dd> -</dl> - -<h3 id="异常事件">异常事件</h3> - -<ul> - <li>如果请求的长度超过 65536 字节,则异常事件 {{domxref("DOMException")}} {{exception("QuotaExceededError")}} 被抛出。</li> -</ul> - -<h2 id="例子">例子</h2> - -<pre class="brush: js">/* 假设 window.crypto.getRandomValues 可用 */ - -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="标准">标准</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</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="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.Crypto.getRandomValues")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>通过 {{ domxref("Window.crypto") }} 获取 {{domxref("Crypto")}} 对象。</li> - <li>{{jsxref("Math.random")}},一个非密码学安全的随机数来源。</li> -</ul> diff --git a/files/zh-cn/web/api/randomsource/index.html b/files/zh-cn/web/api/randomsource/index.html deleted file mode 100644 index 1366009032..0000000000 --- a/files/zh-cn/web/api/randomsource/index.html +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: RandomSource -slug: Web/API/RandomSource -translation_of: Web/API/Crypto/getRandomValues -translation_of_original: Web/API/RandomSource ---- -<p>{{APIRef("Web Crypto API")}}</p> - -<p><strong><code>RandomSource</code></strong> 代表密码学安全随机数的来源。它可以通过全局对象的 {{domxref("Crypto")}} 获取:网页中的 {{domxref("Window.crypto")}},Workrt 里面的 {{domxref("WorkerGlobalScope.crypto")}}。</p> - -<p><code>RandomSource</code> 不是一个接口,这个类型的对象不可以被创建。</p> - -<h2 id="属性">属性</h2> - -<p><em><code>RandomSource</code> 既没有定义也没有属性。</em></p> - -<dl> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{ domxref("RandomSource.getRandomValues()") }}</dt> - <dd>使用密码学可靠的随机值填充传递过来的 {{ domxref("ArrayBufferView") }}。</dd> -</dl> - -<h2 id="Specification" name="Specification">标准</h2> - -<table class="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', '#dfn-RandomSource')}}</td> - <td>{{Spec2('Web Crypto API')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{ CompatibilityTable() }}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>11.0 {{ webkitbug("22049") }}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop(21)}} [1]</td> - <td>11.0</td> - <td>15.0</td> - <td>3.1</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>23</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile(21)}}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>6</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Although the transparent <code>RandomSource</code> is only available since Firefox 26, the feature was available in Firefox 21.</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>通过 {{ domxref("Window.crypto") }} 获取一个 {{domxref("Crypto")}} 对象。</li> - <li>{{jsxref("Math.random")}},一个非密码学安全来源的随机数。</li> -</ul> |