aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/randomsource/index.html
blob: caa31d018f0a17cc6c6d831017261ca35694b86f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
title: RandomSource
slug: Web/API/RandomSource
translation_of: Web/API/Crypto/getRandomValues
---
<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>