You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`-``crypto.secureHeapUsed()` not applicable to RN
@@ -306,6 +307,7 @@ These ciphers are **not available in Node.js** but are provided by RNQC via libs
306
307
- ✅ `crypto.subtle`
307
308
- ✅ `crypto.getRandomValues(typedArray)`
308
309
- ✅ `crypto.randomUUID()`
310
+
- ✅ `crypto.randomUUIDv7()`_(extension; not in WebCrypto spec)_
309
311
- ✅ Class: `CryptoKey`
310
312
- ✅ `cryptoKey.algorithm`
311
313
- ✅ `cryptoKey.extractable`
@@ -378,19 +380,25 @@ These ciphers are **not available in Node.js** but are provided by RNQC via libs
378
380
379
381
## `subtle.digest`
380
382
381
-
| Algorithm | Status |
382
-
| ----------- | :----: |
383
-
|`cSHAKE128`| ✅ |
384
-
|`cSHAKE256`| ✅ |
385
-
|`SHA-1`| ✅ |
386
-
|`SHA-256`| ✅ |
387
-
|`SHA-384`| ✅ |
388
-
|`SHA-512`| ✅ |
389
-
|`SHA3-256`| ✅ |
390
-
|`SHA3-384`| ✅ |
391
-
|`SHA3-512`| ✅ |
392
-
393
-
> **Note:**`cSHAKE128` and `cSHAKE256` provide SHAKE128/SHAKE256 (XOF) functionality with empty customization, matching Node.js behavior. The `length` parameter (in bytes, must be a multiple of 8) is required to specify the output length.
383
+
| Algorithm | Status |
384
+
| --------------- | :----: |
385
+
|`cSHAKE128`| ✅ |
386
+
|`cSHAKE256`| ✅ |
387
+
|`KT128`| ✅ |
388
+
|`KT256`| ✅ |
389
+
|`SHA-1`| ✅ |
390
+
|`SHA-256`| ✅ |
391
+
|`SHA-384`| ✅ |
392
+
|`SHA-512`| ✅ |
393
+
|`SHA3-256`| ✅ |
394
+
|`SHA3-384`| ✅ |
395
+
|`SHA3-512`| ✅ |
396
+
|`TurboSHAKE128`| ✅ |
397
+
|`TurboSHAKE256`| ✅ |
398
+
399
+
> **Note:**`cSHAKE128` and `cSHAKE256` provide SHAKE128/SHAKE256 (XOF) functionality with empty customization, matching Node.js behavior. The `outputLength` parameter (in bytes, must be a multiple of 8) is required to specify the output length.
400
+
>
401
+
> **TurboSHAKE128/256** (RFC 9861) and **KangarooTwelve** (`KT128`, `KT256`) are extendable-output functions (XOFs) requiring an `outputLength` parameter. TurboSHAKE additionally accepts a `domainSeparation` byte; KangarooTwelve accepts a `customization` byte string.
Copy file name to clipboardExpand all lines: docs/content/docs/api/random.mdx
+81-25Lines changed: 81 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,9 @@ Standard random number generators (like `Math.random()`) are **Pseudo-Random Num
22
22
Cryptographically secure systems require **CSPRNGs (Cryptographically Strong PRNGs)**. These are designed to be unpredictable even if an attacker knows the algorithm.
23
23
24
24
RNQC delegates randomness to the underlying Operating System's entropy pool:
25
-
***iOS/macOS**: `SecRandomCopyBytes`
26
-
***Android**: `SecureRandom`
25
+
26
+
-**iOS/macOS**: `SecRandomCopyBytes`
27
+
-**Android**: `SecureRandom`
27
28
28
29
This ensures that generated keys, salts, and nonces are secure.
Populates an *existing* buffer with random data. Works correctly with TypedArray views over larger ArrayBuffers — `offset` and `size` are relative to the view, not the underlying buffer.
76
+
Populates an _existing_ buffer with random data. Works correctly with TypedArray views over larger ArrayBuffers — `offset` and `size` are relative to the view, not the underlying buffer.
72
77
73
78
**Parameters:**
74
79
75
80
<TypeTable
76
81
type={{
77
-
buffer: { description: 'Buffer or TypedArray view to fill.', type: 'Buffer | TypedArray' },
78
-
offset: { description: 'Start position within the view. Default: 0', type: 'number' },
'Accepted for Node.js parity. RNQC pulls fresh OS entropy on every call, so this is a no-op.',
144
+
type: 'boolean',
145
+
},
125
146
}}
126
147
/>
127
148
128
149
**Returns:**`string` e.g. `'f47ac10b-58cc-4372-a567-0e02b2c3d479'`
129
150
130
151
---
131
152
153
+
### randomUUIDv7([options])
154
+
155
+
Generates a random RFC 9562 §5.7 Version 7 UUID. Layout: 48-bit big-endian Unix-ms timestamp prefix, 4-bit version (`7`), 2-bit variant (`10`), and 74 bits of CSPRNG output.
156
+
157
+
The timestamp prefix makes v7 UUIDs **lexicographically sortable by creation time**, which makes them well-suited as primary keys, idempotency tokens, and ordered identifiers.
@@ -185,4 +240,5 @@ async function secureShuffle<T>(array: T[]): Promise<T[]> {
185
240
## Security Considerations
186
241
187
242
### Blocking the Event Loop
243
+
188
244
`randomBytes` (synchronous) taps into system sources. While generally fast, requesting large amounts of entropy on a constrained device could potentially block the Main/UI thread. For generating 4KB or less (keys, nonces), sync is fine. For larger buffers, use the asynchronous version or `randomUUID`.
0 commit comments