From: Chris Duncan Date: Mon, 9 Dec 2024 13:48:30 +0000 (-0800) Subject: Create method to destroy entropy by randomizing its byte values. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=af41c70a2fcb1e6d2dfe946b1d12179b60068d82;p=libnemo.git Create method to destroy entropy by randomizing its byte values. --- 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 + } + } }