Closed scottohara closed 2 days ago
From https://deno.com/blog/v1.11#more-web-crypto-apis-supported:
"Additionally we have added support for the recently standardized crypto.randomUUID function. It allows you to generate UUID v4 as per RFC 4122. This feature is already in Node.js and will ship in Chrome/Edge 92 by the end of next month.
console.log("Random UUID:", crypto.randomUUID());
We aim to expand the Web Crypto APIs in the next release, Deno 1.12, scheduled for July 13th."
See also #11
md5
is used to generate a checksum of the JSON sent (export) or received (import). It would be preferred if we could compute these checksums using a native browser API instead of relying on a 3rd party library.UPDATE: 5-Jul-2023 -
uuid.v4()
has now been replaced withcrypto.randomUUID()
in https://github.com/scottohara/tvmanager/commit/df65c633d8dcf0216bbd75c574f507d2dd6ef2fe(Issue can remain open to track the replacement of
md5
with a native equivalent)uuid
is used to generate v4 UUIDs for all entities. It is possible to generate these in the browser as follows:https://medium.com/teads-engineering/generating-uuids-at-scale-on-the-web-2877f529d2a2> Generating a 128-bit (16 bytes) random number with the Crypto API is as simple as:> To turn these random bytes into a RFC-compliant version 4 UUID, one needs to set the variant and version bits, and then convert the bytes to hexadecimal digits separated by dashes.> The File API does not specify which version of UUID should be used or how it should be generated. In practice, Chromium-based browsers (Chrome and Edge) and WebKit reuse their Crypto implementation to generate random bytes, and then set/clear bits to create a v4 UUID. Firefox calls OS-level functions when they exist (CoCreateGuid on Windows, CFUUIDCreate on macOS), and otherwise falls back to using Crypto like Chromium and WebKit.