vwkd
vwkd3y ago

Sync uuid from string

How can I generate a UUID from a string synchronously? In the standard library I only found this async module https://deno.land/std@0.160.0/uuid/v5.ts?s=generate
5 Replies
crowlKats
crowlKats3y ago
Crypto.randomUUID() - Web APIs | MDN
The randomUUID() method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
vwkd
vwkdOP3y ago
@crowlkats Thanks, I don’t need a random one but one that’s replicable from a input string.
crowlKats
crowlKats3y ago
oh my bad
iuioiua
iuioiua3y ago
You’ll have to create your own generateSync function using crypto.subtle.digestSync.
vwkd
vwkdOP3y ago
I ended up using uuid-by-string from NPM https://www.npmjs.com/package/uuid-by-string
npm
uuid-by-string
Generating uuid-hash from string. Latest version: 4.0.0, last published: a month ago. Start using uuid-by-string in your project by running npm i uuid-by-string. There are 76 other projects in the npm registry using uuid-by-string.