diff options
Diffstat (limited to 'ext/mixed')
-rw-r--r-- | ext/mixed/js/core.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index 2dd9cf40..b6ecb48b 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -257,6 +257,16 @@ const yomichan = (() => { // Public + generateId(length) { + const array = new Uint8Array(length); + window.crypto.getRandomValues(array); + let id = ''; + for (const value of array) { + id += value.toString(16).padStart(2, '0'); + } + return id; + } + triggerOrphaned(error) { this.trigger('orphaned', {error}); } |