温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/crypto/randomFillSync
点击访问原文链接

Node crypto.randomFillSync function | API Reference | Bun

Node crypto.randomFillSync function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:crypto/randomFillSyncFrandomFillSync

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:crypto/randomFillSyncFrandomFillSync

function

crypto.randomFillSyncfunction randomFillSyncT extends ArrayBufferViewArrayBufferLike>>(buffer: T,offset?: number,size?: number): T;

Synchronous version of randomFill.

import { Buffer } from 'node:buffer';
const { randomFillSync } = await import('node:crypto');

const buf = Buffer.alloc(10);
console.log(randomFillSync(buf).toString('hex'));

randomFillSync(buf, 5);
console.log(buf.toString('hex'));

// The above is equivalent to the following:
randomFillSync(buf, 5, 5);
console.log(buf.toString('hex'));

Any ArrayBuffer, TypedArray or DataView instance may be passed asbuffer.

import { Buffer } from 'node:buffer';
const { randomFillSync } = await import('node:crypto');

const a = new Uint32Array(10);
console.log(Buffer.from(randomFillSync(a).buffer,
a.byteOffset, a.byteLength).toString('hex'));

const b = new DataView(new ArrayBuffer(10));
console.log(Buffer.from(randomFillSync(b).buffer,
b.byteOffset, b.byteLength).toString('hex'));

const c = new ArrayBuffer(10);
console.log(Buffer.from(randomFillSync(c)).toString('hex'));
@param buffer

Must be supplied. The size of the provided buffer must not be larger than 2**31 - 1.

@returns

The object passed as buffer argument.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node crypto.randomFillSync function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:crypto.randomFillSync | Bun