User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
1 โ€“ 1024
Presets:
Configure options and click Generate
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

A nibble (also nybble) is a 4-bit aggregation - half an octet. Its value domain spans 0 to 15 (0x0 - 0xF). Nibbles are the atomic unit of hexadecimal notation: every hex digit encodes exactly one nibble. In memory-mapped I/O, BCD arithmetic, and legacy telecom protocols (SMS PDU encoding), nibble-level manipulation is routine. Generating nibbles with a weak PRNG (Math.random) produces statistically biased output unsuitable for key material, nonce construction, or Monte Carlo sampling. This tool uses the browser's crypto.getRandomValues CSPRNG, seeded from OS entropy, which satisfies NIST SP 800-90A requirements.

Each generated value is masked to 4 bits via bitwise AND with 0x0F, discarding the upper nibble of each random byte. The tool computes Shannon entropy H across the output set. For a uniform distribution over 16 symbols, maximum entropy is 4.0 bits. Deviations indicate sampling artifacts at small sample sizes. Generate at least 256 nibbles to observe convergence toward uniformity. Note: this tool approximates statistical quality for visual inspection only - it does not replace NIST STS or Diehard test suites.

random nibble generator 4-bit random nibble binary hex random number generator cryptographic random nibble converter bit generator

Formulas

Each nibble is extracted from a cryptographically random byte by masking the upper four bits:

nibble = byte & 0x0F

This isolates bits 0 - 3, yielding a uniform value in [0, 15]. Shannon entropy for the generated set is computed as:

H = โˆ’ 15โˆ‘i=0 p(i) โ‹… log2 p(i)

where p(i) = count(i)N is the observed frequency of nibble value i in N total samples. For a perfectly uniform distribution across 16 symbols, Hmax = log2(16) = 4.0 bits. The ratio HHmax expresses efficiency of the source. Values below 0.95 at N โ‰ฅ 256 suggest non-uniformity.

Reference Data

Nibble (Dec)BinaryHexOctalBCD DigitASCII Char (0x30+n)7-Segment Code
0000000000 (0x30)0x3F
1000110111 (0x31)0x06
2001020222 (0x32)0x5B
3001130333 (0x33)0x4F
4010040444 (0x34)0x66
5010150555 (0x35)0x6D
6011060666 (0x36)0x7D
7011170777 (0x37)0x07
8100081088 (0x38)0x7F
9100191199 (0x39)0x6F
101010A12Invalid: (0x3A)0x77
111011B13Invalid; (0x3B)0x7C
121100C14Invalid< (0x3C)0x39
131101D15Invalid= (0x3D)0x5E
141110E16Invalid> (0x3E)0x79
151111F17Invalid? (0x3F)0x71

Frequently Asked Questions

Math.random uses a PRNG (typically xorshift128+) that is deterministic given its seed. Its output fails statistical randomness tests required by NIST SP 800-22. crypto.getRandomValues draws from the OS entropy pool (e.g., /dev/urandom on Linux, BCryptGenRandom on Windows), producing cryptographically secure output suitable for nonce generation, key material, and unbiased sampling.
A random byte from a uniform source has 256 equally probable values. Masking with 0x0F maps each byte to its lower 4 bits. Since 256 รท 16 = 16 (an integer), exactly 16 byte values map to each nibble value. No modular bias occurs because the range divides evenly.
Maximum entropy for 16 equiprobable symbols is 4.0 bits. Values below this indicate non-uniform distribution. At small sample sizes (N < 64), deviations are expected due to sampling variance. The standard deviation of entropy for N uniform samples is approximately 152 โ‹… N โ‹… ln(2). Generate 512+ nibbles to observe convergence.
No. Binary-Coded Decimal restricts each nibble to 0 - 9. Nibble values 10 - 15 (0xA - 0xF) are invalid in BCD and often used as sign indicators (e.g., 0xC for positive, 0xD for negative in packed BCD). If you need BCD-safe output, filter or regenerate nibbles exceeding 9.
A byte contains 2 nibbles. A 16-bit word holds 4. A 32-bit integer holds 8. A 64-bit long holds 16. IPv4 addresses occupy 8 nibbles. An MD5 hash is 32 nibbles (128 bits). A SHA-256 digest is 64 nibbles.
Yes. This tool discards bits 4-7 of each byte. For N nibbles, it consumes N bytes of entropy. An optimization would pack two nibbles per byte (upper and lower), halving entropy consumption. This implementation prioritizes simplicity and auditability over entropy efficiency.