# secure-random-bytes

> Retrieve a secure random byte string of a specified length

Latest version **7.0.2** (published 2026-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install secure-random-bytes
pnpm add secure-random-bytes
yarn add secure-random-bytes
bun add secure-random-bytes
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 7.0.2 |
| Published | 2026-09-09 |
| First published | 2014-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 22 \|\| >=24 |
| Dependencies | 1 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Kenan Yildirim <kenan@kenany.me> (https://kenany.me/) |
| Maintainers | kenan |
| Keywords | crypto, random |

## Links

- npm: https://www.npmjs.com/package/secure-random-bytes
- Repository: https://github.com/kenany/secure-random-bytes
- npm.io page: https://npm.io/package/secure-random-bytes

## Dependencies (1)

- [secure-random-octet](https://npm.io/package/secure-random-octet.md) ^6.0.1

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 7.0.2 (latest) — 2026-09-09
- 7.0.1 — 2026-06-04
- 7.0.0 — 2026-05-13
- 6.0.5 — 2026-05-05
- 6.0.4 — 2026-04-30
- 6.0.3 — 2026-04-13
- 6.0.2 — 2025-11-24
- 6.0.1 — 2025-09-19
- 6.0.0 — 2025-09-19
- 5.0.1 — 2023-11-01
- 5.0.0 — 2023-09-21
- 4.0.2 — 2023-04-21
- 4.0.1 — 2022-09-30
- 4.0.0 — 2022-09-30
- 3.0.1 — 2021-08-18
- … 7 more at https://npm.io/package/secure-random-bytes/versions

## README

# secure-random-bytes

Retrieve a secure random byte string of a specified length.

## Example

```javascript
const randomBytes = require("secure-random-bytes");

randomBytes(10);
// => 'ÊïÜsóÐ\u0006\u0016mÏ'
```

## Installation

```bash
$ npm install secure-random-bytes
```

## API

```javascript
const randomBytes = require("secure-random-bytes");
```

### `randomBytes(length)`

Returns a _String_ (whose length is `length`) of random bytes.

---
_Source: https://npm.io/package/secure-random-bytes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
