From af41c70a2fcb1e6d2dfe946b1d12179b60068d82 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 9 Dec 2024 05:48:30 -0800 Subject: [PATCH] Create method to destroy entropy by randomizing its byte values. --- src/lib/entropy.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/entropy.ts b/src/lib/entropy.ts index 295c8d3..3fb5cba 100644 --- a/src/lib/entropy.ts +++ b/src/lib/entropy.ts @@ -117,4 +117,16 @@ export class Entropy { reject(new TypeError(`Entropy cannot import ${typeof input}`)) }) } + + /** + * Randomizes the bytes, rendering the original values generally inaccessible. + */ + destroy (): boolean { + try { + crypto.getRandomValues(this.#bytes) + return true + } catch (err) { + return false + } + } } -- 2.34.1