Skip to content

Add randomUUID() support#290

Open
Syed-Moiz-Ali wants to merge 1 commit into
google:masterfrom
Syed-Moiz-Ali:feat/random-uuid
Open

Add randomUUID() support#290
Syed-Moiz-Ali wants to merge 1 commit into
google:masterfrom
Syed-Moiz-Ali:feat/random-uuid

Conversation

@Syed-Moiz-Ali

Copy link
Copy Markdown

Fixes #187

Adds
andomUUID()\ function matching the \Crypto.randomUUID()\ Web API:

  • JS backend: delegates to \window.crypto.randomUUID()\ via \dart:js_interop\
  • FFI backend: generates UUID v4 using BoringSSL \RAND_bytes\ with correct version (4) and variant (RFC 4122) bits
  • Stub backend: throws \UnimplementedError\

The public API is a top-level \String randomUUID()\ function in \package:webcrypto.

Tests verify:

  • UUID format (length, dashes, version nibble, variant nibble, hex characters)
  • Uniqueness across 100 generated UUIDs

Implements Crypto.randomUUID() from the Web Crypto specification
across all backends:

- JS backend: delegates to window.crypto.randomUUID() via dart:js_interop
- FFI backend: generates UUID v4 using BoringSSL RAND_bytes
- Stub backend: throws UnimplementedError

The public API is exposed as a top-level randomUUID() function that
returns a version 4 UUID string in the format
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.

Fixes google#187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding support for randomUUID

1 participant