manifest/nuxt/composables/crypto.js

11 lines
285 B
JavaScript

import * as cryptoServer from 'crypto'
export const useCrypto = () => {
return {
getRandomUUID: () => (typeof window === 'undefined')
? cryptoServer.randomBytes(16).toString('hex') // Server code
: crypto.randomUUID() // Browser code
}
}