From 310fd066e91f454b990372ffa30e803cc8120975 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:56:40 +0100 Subject: unslug zh-cn: move --- .../api/randomsource/getrandomvalues/index.html | 77 --------------- files/zh-cn/web/api/randomsource/index.html | 107 --------------------- 2 files changed, 184 deletions(-) delete mode 100644 files/zh-cn/web/api/randomsource/getrandomvalues/index.html delete mode 100644 files/zh-cn/web/api/randomsource/index.html (limited to 'files/zh-cn/web/api/randomsource') 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 ---- -

{{APIRef("Web Crypto API")}}

- -

Crypto.getRandomValues() 方法让你可以获取符合密码学要求的安全的随机值。传入参数的数组被随机值填充(在加密意义上的随机)。

- -

为了确保足够的性能,不使用真正的随机数生成器,但是它们正在使用具有足够熵值伪随机数生成器。它所使用的 PRNG 的实现与其他不同,但适用于加密的用途。该实现还需要使用具有足够熵的种子,如系统级熵源。

- -

语法

- -
cryptoObj.getRandomValues(typedArray);
- -

参数

- -
-
typedArray
-
是一个基于整数的 {{jsxref("TypedArray")}},它可以是 {{jsxref("Int8Array")}}、{{jsxref("Uint8Array")}}、{{jsxref("Int16Array")}}、 {{jsxref("Uint16Array")}}、 {{jsxref("Int32Array")}} 或者 {{jsxref("Uint32Array")}}。在数组中的所有的元素会被随机数重写。(注释:生成的随机数储存在 typedArray 数组上。)
-
- -

异常事件

- - - -

例子

- -
/* 假设 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]);
-}
-
- -

标准

- - - - - - - - - - - - - - -
规范状态备注
{{SpecName('Web Crypto API', '#RandomSource-method-getRandomValues')}}{{Spec2('Web Crypto API')}}Initial definition
- -

浏览器兼容性

- - - -

{{Compat("api.Crypto.getRandomValues")}}

- -

参见

- - 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 ---- -

{{APIRef("Web Crypto API")}}

- -

RandomSource 代表密码学安全随机数的来源。它可以通过全局对象的 {{domxref("Crypto")}} 获取:网页中的 {{domxref("Window.crypto")}},Workrt 里面的 {{domxref("WorkerGlobalScope.crypto")}}。

- -

RandomSource 不是一个接口,这个类型的对象不可以被创建。

- -

属性

- -

RandomSource 既没有定义也没有属性。

- -
-
- -

方法

- -
-
{{ domxref("RandomSource.getRandomValues()") }}
-
使用密码学可靠的随机值填充传递过来的 {{ domxref("ArrayBufferView") }}。
-
- -

标准

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Web Crypto API', '#dfn-RandomSource')}}{{Spec2('Web Crypto API')}}Initial definition
- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support11.0 {{ webkitbug("22049") }}{{CompatVersionUnknown}}{{CompatGeckoDesktop(21)}} [1]11.015.03.1
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}23{{CompatVersionUnknown}}{{CompatGeckoMobile(21)}}{{ CompatNo() }}{{ CompatNo() }}6
-
- -

[1] Although the transparent RandomSource is only available since Firefox 26, the feature was available in Firefox 21.

- -

参见

- - -- cgit v1.2.3-54-g00ecf