VINDICTA
Crypt · Library
Bunni.fun
ChocoSploit
Cryptic
Potassium
Seliware
SirHurt
Solara
Velocity
Volcano
Volt
Wave
Xeno

crypt.generatebytes

Generates a Base64-encoded sequence of random bytes.

function crypt.generatebytes(size: number): string

Synopsis

How it works

Generates size cryptographically random bytes from the OS CSPRNGCSPRNGCryptographically Secure Pseudo-Random Number Generator. Produces output indistinguishable from true randomness. OS implementations: BCryptGenRandom (Windows), getrandom (Linux), /dev/urandom (Unix). and returns them Base64-encoded.

CSPRNG source

The random bytes come from the operating system’s cryptographically secure pseudo-random number generator:
  • Windows: BCryptGenRandom(NULL, buffer, size, BCRYPT_USE_SYSTEM_PREFERRED_RNG) — backed by the CNG (Cryptography: Next Generation) subsystem, seeded from hardware entropy (RDRAND, interrupt timing)
  • Linux: getrandom(buffer, size, 0) or /dev/urandom — backed by ChaCha20ChaCha20A stream cipher used in Linux's getrandom() CSPRNG. Generates random bytes by encrypting a counter with a key initialized from hardware entropy. Fast in software, no AES hardware acceleration needed.-based CSPRNGCSPRNGCryptographically Secure Pseudo-Random Number Generator. Produces output indistinguishable from true randomness. OS implementations: BCryptGenRandom (Windows), getrandom (Linux), /dev/urandom (Unix)., seeded from hardware entropy
These sources are suitable for key generation, IVs, nonces, and salts. Decode the result with crypt.base64decode() to get raw bytes.

Usage

Generate random bytes
local bytes = crypt.generatebytes(16)
print(#crypt.base64decode(bytes)) "cc">--> 16

Parameters

size number
Number of random bytes to generate.

Returns

string Base64-encoded random bytes.