--- title: RandomSource slug: Web/API/RandomSource tags: - API - Interface - NeedsTranslation - RandomSource - Reference - TopicStub - Web Crypto API translation_of: Web/API/Crypto/getRandomValues ---

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

RandomSource represents a source of cryptographically secure random numbers. It is available via the {{domxref("Crypto")}} object of the global object: {{domxref("Window.crypto")}} on Web pages, {{domxref("WorkerGlobalScope.crypto")}} in workers.

RandomSource is a not an interface and no object of this type can be created.

Properties

RandomSource neither defines nor inherits any property.

Methods

{{ domxref("RandomSource.getRandomValues()") }}
Fills the passed {{ domxref("ArrayBufferView") }} with cryptographically sound random values.

Specification

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

Browser Compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 11.0 {{ webkitbug("22049") }} {{CompatGeckoDesktop(21)}} [1] 11.0 15.0 3.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} 23 {{CompatGeckoMobile(21)}} {{ CompatNo() }} {{ CompatNo() }} 6

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

See also