
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
deca-random-data
Advanced tools
Cryptographically secure random byte and number generator with multiple encoding support
A comprehensive, cryptographically secure random byte and number generator with multiple encoding support. ๐๐
npm install deca-random-bytes
deca-random-bytes/
โ
โโโ src/
โ โโโ index.ts # Main source file
โ
โโโ dist/ # Compiled JavaScript files
โ โโโ index.js
โ โโโ index.d.ts # TypeScript declaration file
โ
โโโ tests/
โ โโโ index.test.ts # Unit tests
โ
โโโ package.json # Project configuration
โโโ tsconfig.json # TypeScript configuration
โโโ README.md # Project documentation
import { decaRandomBytes } from 'deca-random-bytes';
// Generate 16 random bytes in hex (default)
const hexToken = decaRandomBytes(16);
// Generate in different encodings
const base64Token = decaRandomBytes(16, 'base64');
const utf8Token = decaRandomBytes(16, 'utf8');
import { decaMultiRandomBytes } from 'deca-random-bytes';
const tokens = decaMultiRandomBytes({
apiToken: { bytes: 16, encoding: 'hex' },
userId: { bytes: 8, encoding: 'base64url' },
sessionKey: { bytes: 32, encoding: 'base64' }
});
console.log(tokens.apiToken); // Hex-encoded random bytes
console.log(tokens.userId); // Base64URL-encoded random bytes
console.log(tokens.sessionKey); // Base64-encoded random bytes
import { decaRandomInt } from 'deca-random-bytes';
// Generate a random integer between 1 and 100 (inclusive)
const randomNumber = decaRandomInt(1, 100);
console.log(randomNumber);
hex: Hexadecimal encoding ๐ขbase64: Base64 encoding ๐utf8: UTF-8 text encoding ๐ascii: ASCII encoding ๐ปbase64url: URL-safe Base64 encoding ๐Works in both browser and Node.js environments with cryptographically secure random number generation. ๐ฅ๏ธ ๐ฑ
MIT License ๐๏ธ
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
Tom Tarpey
FAQs
Cryptographically secure random byte and number generator with multiple encoding support
We found that deca-random-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.ย It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.