@guanghechen/byte 2.0.1 → 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 CHANGED
@@ -1,8 +1,43 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Overwrite buffers with cryptographically strong random data.
8
+
9
+ ## 2.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - chore: vitest config auto-load aliases and coverage thresholds; style/doc formatting updates
14
+
3
15
  All notable changes to this project will be documented in this file. See
4
16
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
17
 
18
+ ## 2.0.1 (2025-02-07)
19
+
20
+ ### Improvements
21
+
22
+ - Use `node:` protocol for builtin module imports
23
+ - Clean up build configs and standardize package exports
24
+
25
+ ### Documentation
26
+
27
+ - Update README.md
28
+
29
+ ### Miscellaneous
30
+
31
+ - Add LICENSE file
32
+ - Migrate from lerna to changesets
33
+
34
+ ## 2.0.0 (2025-01-15)
35
+
36
+ ### Improvements
37
+
38
+ - Upgrade to stable release
39
+ - Switch to recommended ESLint stack
40
+
6
41
  ## 1.0.0-alpha.7 (2024-09-18)
7
42
 
8
43
  - :art: format codes ([177eb54](https://github.com/guanghechen/sora/commit/177eb54))
package/lib/cjs/index.cjs CHANGED
@@ -187,9 +187,7 @@ function bytes2text(bytes, encoding) {
187
187
  }
188
188
 
189
189
  function destroyBytes(bytes) {
190
- bytes.fill(0);
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.fill(0);
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)
@@ -20,7 +20,7 @@ declare function utf8Text2bytes(utf8Text: string): Uint8Array;
20
20
  declare function bytes2utf8Text(bytes: Readonly<Uint8Array>): string;
21
21
 
22
22
  /**
23
- * Fill the bytes with random numbers.
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanghechen/byte",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Utility functions for bytes (Uint8Array).",
5
5
  "author": {
6
6
  "name": "guanghechen",