Initial Commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Overwrite `buf` in-place with zero bytes.
|
||||
*
|
||||
* JavaScript cannot guarantee the garbage collector has not already relocated
|
||||
* or copied the underlying memory, so this is a best-effort operation. Its
|
||||
* purpose is to minimise the time window during which sensitive bytes
|
||||
* (secret keys, plaintext, derived material) remain readable on the heap
|
||||
* after they are no longer needed. Combine with aggressive buffer
|
||||
* scoping — allocate inside a function, zeroize, return nothing sensitive.
|
||||
*/
|
||||
export function zeroize(buf: Uint8Array): void {
|
||||
buf.fill(0);
|
||||
}
|
||||
Reference in New Issue
Block a user