[whatwg] Cryptographically strong random numbers
cedricv at neonux.com
Sat Feb 5 20:07:10 PST 2011
On Sun, Feb 6, 2011 at 11:34, Roger Hågensen <rescator at emsai.net> wrote:
> But getRandomValues(in ArrayBufferView data) seem to indicate that each byte
> (value) is random, limited to an array of 8bit data?.
In the context of typed arrays, a value depends of the type of the
ArrayBufferView. ArrayBufferView are interchangable using the same
ArrayBuffer (the actual underlying bytes).
Passing an Uint8Array will give you random Uint8 values at each index
of the array, passing an Int32Array will give you random Int32 values
at each index of the array as well.
Technically the implementation is the same for any integer array :
filling the underlying array buffer (bytes) with random data, eg :
read(FD("/dev/random"), PTR(arraybufferview->data), arraybufferview->byteLength)
More information about the whatwg