mirror of
https://github.com/hanzoai/jose.git
synced 2026-09-24 17:00:01 +00:00
11 lines
264 B
TypeScript
11 lines
264 B
TypeScript
// @ts-ignore
|
|
const nodeCrypto = await import('crypto').catch(() => {})
|
|
|
|
export default (byteLength = 16) => {
|
|
try {
|
|
return crypto.getRandomValues(new Uint8Array(byteLength))
|
|
} catch {
|
|
return nodeCrypto.randomFillSync(new Uint8Array(byteLength))
|
|
}
|
|
}
|