@guanghechen/byte 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/index.cjs +1 -3
- package/lib/esm/index.mjs +2 -4
- package/lib/types/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/cjs/index.cjs
CHANGED
|
@@ -187,9 +187,7 @@ function bytes2text(bytes, encoding) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function destroyBytes(bytes) {
|
|
190
|
-
|
|
191
|
-
bytes.fill(1);
|
|
192
|
-
bytes.fill(Math.random() * 127);
|
|
190
|
+
node_crypto.randomFillSync(bytes);
|
|
193
191
|
}
|
|
194
192
|
function destroyBytesList(bytesList) {
|
|
195
193
|
for (const bytes of bytesList)
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomBytes as randomBytes$1 } from 'node:crypto';
|
|
1
|
+
import { randomFillSync, randomBytes as randomBytes$1 } from 'node:crypto';
|
|
2
2
|
|
|
3
3
|
const CODES = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
4
4
|
const CODE_PADDING = '=';
|
|
@@ -185,9 +185,7 @@ function bytes2text(bytes, encoding) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
function destroyBytes(bytes) {
|
|
188
|
-
bytes
|
|
189
|
-
bytes.fill(1);
|
|
190
|
-
bytes.fill(Math.random() * 127);
|
|
188
|
+
randomFillSync(bytes);
|
|
191
189
|
}
|
|
192
190
|
function destroyBytesList(bytesList) {
|
|
193
191
|
for (const bytes of bytesList)
|
package/lib/types/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare function utf8Text2bytes(utf8Text: string): Uint8Array;
|
|
|
20
20
|
declare function bytes2utf8Text(bytes: Readonly<Uint8Array>): string;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Overwrite the bytes in place with cryptographically strong random data.
|
|
24
24
|
* @param bytes
|
|
25
25
|
*/
|
|
26
26
|
declare function destroyBytes(bytes: Uint8Array): void;
|