No results for

Powered byAlgolia
⚠️ This is archived documentation for v0.32. Go to the latest version

randomBytes( int )

suggest edits

Return an ArrayBuffer object with a number of cryptographically random bytes. It will either return exactly the amount of bytes requested or will throw an exception if something went wrong.

intintegerThe length of the returned ArrayBuffer.


ArrayBufferAn ArrayBuffer with cryptographically random bytes.


import crypto from 'k6/crypto';
export default function () {
const bytes = crypto.randomBytes(42);
const view = new Uint8Array(bytes);
console.log(view); // 156,71,245,191,56,...