@stryke/hash 0.12.52 → 0.13.0

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.cjs +20 -19
  3. package/dist/index.d.cts +2 -7
  4. package/dist/index.d.mts +2 -7
  5. package/dist/index.mjs +2 -7
  6. package/dist/neutral-CDggl_ee.cjs +739 -0
  7. package/dist/neutral-D7D-RtyE.mjs +601 -0
  8. package/dist/neutral-D7D-RtyE.mjs.map +1 -0
  9. package/dist/neutral-DqpQs0yN.d.cts +162 -0
  10. package/dist/neutral-DqpQs0yN.d.cts.map +1 -0
  11. package/dist/neutral-DvfYl4mT.d.mts +162 -0
  12. package/dist/neutral-DvfYl4mT.d.mts.map +1 -0
  13. package/dist/neutral.cjs +20 -14
  14. package/dist/neutral.d.cts +2 -5
  15. package/dist/neutral.d.mts +2 -5
  16. package/dist/neutral.mjs +2 -5
  17. package/dist/node.cjs +659 -0
  18. package/dist/node.d.cts +172 -0
  19. package/dist/node.d.cts.map +1 -0
  20. package/dist/node.d.mts +172 -0
  21. package/dist/node.d.mts.map +1 -0
  22. package/dist/node.mjs +613 -0
  23. package/dist/node.mjs.map +1 -0
  24. package/package.json +41 -24
  25. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  26. package/dist/convert/src/array-buffer-to-string.cjs +0 -19
  27. package/dist/convert/src/array-buffer-to-string.mjs +0 -19
  28. package/dist/convert/src/array-buffer-to-string.mjs.map +0 -1
  29. package/dist/convert/src/neutral.cjs +0 -5
  30. package/dist/convert/src/neutral.mjs +0 -7
  31. package/dist/convert/src/parse-type-definition.cjs +0 -1
  32. package/dist/convert/src/parse-type-definition.mjs +0 -3
  33. package/dist/convert/src/string-to-uint8-array.cjs +0 -14
  34. package/dist/convert/src/string-to-uint8-array.mjs +0 -14
  35. package/dist/convert/src/string-to-uint8-array.mjs.map +0 -1
  36. package/dist/convert/src/string-to-utf8-array.cjs +0 -5
  37. package/dist/convert/src/string-to-utf8-array.mjs +0 -6
  38. package/dist/convert/src/string-to-utf8-array.mjs.map +0 -1
  39. package/dist/convert/src/utf8-array-to-string.cjs +0 -5
  40. package/dist/convert/src/utf8-array-to-string.mjs +0 -6
  41. package/dist/convert/src/utf8-array-to-string.mjs.map +0 -1
  42. package/dist/digest.cjs +0 -56
  43. package/dist/digest.d.cts +0 -32
  44. package/dist/digest.d.cts.map +0 -1
  45. package/dist/digest.d.mts +0 -32
  46. package/dist/digest.d.mts.map +0 -1
  47. package/dist/digest.mjs +0 -54
  48. package/dist/digest.mjs.map +0 -1
  49. package/dist/etag.cjs +0 -53
  50. package/dist/etag.d.cts +0 -22
  51. package/dist/etag.d.cts.map +0 -1
  52. package/dist/etag.d.mts +0 -22
  53. package/dist/etag.d.mts.map +0 -1
  54. package/dist/etag.mjs +0 -52
  55. package/dist/etag.mjs.map +0 -1
  56. package/dist/fs/src/list-files.cjs +0 -36
  57. package/dist/fs/src/list-files.d.cts +0 -7
  58. package/dist/fs/src/list-files.d.cts.map +0 -1
  59. package/dist/fs/src/list-files.d.mts +0 -7
  60. package/dist/fs/src/list-files.d.mts.map +0 -1
  61. package/dist/fs/src/list-files.mjs +0 -35
  62. package/dist/fs/src/list-files.mjs.map +0 -1
  63. package/dist/fs/src/read-file.cjs +0 -16
  64. package/dist/fs/src/read-file.mjs +0 -16
  65. package/dist/fs/src/read-file.mjs.map +0 -1
  66. package/dist/hash-files.cjs +0 -41
  67. package/dist/hash-files.d.cts +0 -24
  68. package/dist/hash-files.d.cts.map +0 -1
  69. package/dist/hash-files.d.mts +0 -24
  70. package/dist/hash-files.d.mts.map +0 -1
  71. package/dist/hash-files.mjs +0 -41
  72. package/dist/hash-files.mjs.map +0 -1
  73. package/dist/md5.cjs +0 -17
  74. package/dist/md5.d.cts +0 -12
  75. package/dist/md5.d.cts.map +0 -1
  76. package/dist/md5.d.mts +0 -12
  77. package/dist/md5.d.mts.map +0 -1
  78. package/dist/md5.mjs +0 -17
  79. package/dist/md5.mjs.map +0 -1
  80. package/dist/murmurhash.cjs +0 -22
  81. package/dist/murmurhash.d.cts +0 -23
  82. package/dist/murmurhash.d.cts.map +0 -1
  83. package/dist/murmurhash.d.mts +0 -23
  84. package/dist/murmurhash.d.mts.map +0 -1
  85. package/dist/murmurhash.mjs +0 -22
  86. package/dist/murmurhash.mjs.map +0 -1
  87. package/dist/path/src/is-type.cjs +0 -28
  88. package/dist/path/src/is-type.mjs +0 -29
  89. package/dist/path/src/is-type.mjs.map +0 -1
  90. package/dist/path/src/join-paths.cjs +0 -122
  91. package/dist/path/src/join-paths.mjs +0 -123
  92. package/dist/path/src/join-paths.mjs.map +0 -1
  93. package/dist/path/src/regex.cjs +0 -12
  94. package/dist/path/src/regex.mjs +0 -9
  95. package/dist/path/src/regex.mjs.map +0 -1
  96. package/dist/path/src/slash.cjs +0 -15
  97. package/dist/path/src/slash.mjs +0 -15
  98. package/dist/path/src/slash.mjs.map +0 -1
  99. package/dist/type-checks/src/index.cjs +0 -4
  100. package/dist/type-checks/src/index.mjs +0 -6
  101. package/dist/type-checks/src/is-buffer.cjs +0 -12
  102. package/dist/type-checks/src/is-buffer.mjs +0 -12
  103. package/dist/type-checks/src/is-buffer.mjs.map +0 -1
  104. package/dist/type-checks/src/is-collection.cjs +0 -1
  105. package/dist/type-checks/src/is-collection.mjs +0 -3
  106. package/dist/type-checks/src/is-string.cjs +0 -12
  107. package/dist/type-checks/src/is-string.mjs +0 -12
  108. package/dist/type-checks/src/is-string.mjs.map +0 -1
  109. package/dist/type-checks/src/type-detect.cjs +0 -15
  110. package/dist/type-checks/src/type-detect.mjs +0 -17
  111. package/dist/type-checks/src/type-detect.mjs.map +0 -1
  112. package/dist/xx-hash.cjs +0 -25
  113. package/dist/xx-hash.d.cts +0 -7
  114. package/dist/xx-hash.d.cts.map +0 -1
  115. package/dist/xx-hash.d.mts +0 -7
  116. package/dist/xx-hash.d.mts.map +0 -1
  117. package/dist/xx-hash.mjs +0 -23
  118. package/dist/xx-hash.mjs.map +0 -1
@@ -0,0 +1,172 @@
1
+ import { GlobOptions } from "glob";
2
+
3
+ //#region src/digest.d.ts
4
+ type AlgorithmIdentifier = "SHA-256" | "SHA-384" | "SHA-512";
5
+ /**
6
+ * Creates a new hash object for the specified algorithm.
7
+ *
8
+ * @param algorithm - The algorithm to use for the hash.
9
+ * @returns A new hash object.
10
+ */
11
+ declare function createHasher(algorithm: AlgorithmIdentifier): Hasher;
12
+ /**
13
+ * Creates a new hash object for the specified algorithm.
14
+ *
15
+ * @remarks
16
+ * This function uses the Web Crypto API to create a hash of the input data.
17
+ *
18
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
19
+ *
20
+ * @param data - The data to hash.
21
+ * @param algorithm - The algorithm to use for the hash.
22
+ * @returns A hash string representation of the `data` parameter.
23
+ */
24
+ declare function digest(data: string | Uint8Array, algorithm?: AlgorithmIdentifier): Promise<string>;
25
+ /**
26
+ * Alias for {@link digest}.
27
+ */
28
+ declare const hash: typeof digest;
29
+ /**
30
+ * Hash a string or Uint8Array using SHA-256 and return the result as a base64url-encoded string.
31
+ *
32
+ * @param data - The data to hash.
33
+ * @returns A hash string representation of the `data` parameter.
34
+ */
35
+ declare const sha256: (data: string | Uint8Array) => Promise<string>;
36
+ /**
37
+ * Hash a string or Uint8Array using SHA-384 and return the result as a base64url-encoded string.
38
+ *
39
+ * @param data - The data to hash.
40
+ * @returns A hash string representation of the `data` parameter.
41
+ */
42
+ declare const sha384: (data: string | Uint8Array) => Promise<string>;
43
+ /**
44
+ * Hash a string or Uint8Array using SHA-512 and return the result as a base64url-encoded string.
45
+ *
46
+ * @param data - The data to hash.
47
+ * @returns A hash string representation of the `data` parameter.
48
+ */
49
+ declare const sha512: (data: string | Uint8Array) => Promise<string>;
50
+ declare class Hasher {
51
+ #private;
52
+ constructor(algorithm: AlgorithmIdentifier);
53
+ update(data: Uint8Array): void;
54
+ digest(): Promise<Uint8Array>;
55
+ }
56
+ //#endregion
57
+ //#region src/etag.d.ts
58
+ /**
59
+ * FNV-1a Hash implementation
60
+ *
61
+ * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
62
+ *
63
+ * @remarks
64
+ * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
65
+ * and still making use of Javascript's 53-bit integer space.
66
+ */
67
+ declare const fnv1a52: (str: string) => number;
68
+ /**
69
+ * Generates an ETag for the given payload.
70
+ *
71
+ * @param payload - The payload to generate an ETag for.
72
+ * @param weak - Whether to generate a weak ETag.
73
+ * @returns The generated ETag.
74
+ */
75
+ declare const generateETag: (payload: string, weak?: boolean) => string;
76
+ //#endregion
77
+ //#region src/hash-content.d.ts
78
+ /**
79
+ * Hash the content of a PDU (Protocol Data Unit) by removing the `signatures` and `unsigned` fields, then hashing the remaining content using SHA-256 and encoding it as a base64url string. This function is useful for generating a consistent hash of the PDU content that can be used for integrity verification or caching purposes, while ignoring any fields that may change due to signatures or unsigned data.
80
+ *
81
+ * @param content - The PDU content to hash, represented as a record of string keys and unknown values.
82
+ * @returns A promise that resolves to a base64url-encoded string representing the hash of the PDU content.
83
+ */
84
+ declare function hashContent(content: Record<string, unknown>): Promise<string>;
85
+ /**
86
+ * Verify the hash of a PDU (Protocol Data Unit) content by hashing the content using the {@link hashContent} function and comparing it to an expected hash value. This function is useful for validating the integrity of the PDU content by ensuring that the computed hash matches the expected hash, which can be used to detect any tampering or corruption of the content.
87
+ *
88
+ * @param content - The PDU content to verify, represented as a record of string keys and unknown values.
89
+ * @param expectedHash - The expected hash value to compare against, represented as a string.
90
+ * @returns A promise that resolves to a boolean indicating whether the computed hash of the content matches the expected hash value (true if they match, false otherwise).
91
+ */
92
+ declare function verifyContent(content: Record<string, unknown>, expectedHash: string): Promise<boolean>;
93
+ //#endregion
94
+ //#region ../fs/src/list-files.d.ts
95
+ type ListOptions = GlobOptions;
96
+ //#endregion
97
+ //#region src/murmurhash.d.ts
98
+ interface HashOptions {
99
+ /**
100
+ * The maximum length of the hash
101
+ *
102
+ * @defaultValue 32
103
+ */
104
+ maxLength?: number;
105
+ }
106
+ /**
107
+ * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.
108
+ *
109
+ * @see https://github.com/ohash/ohash
110
+ * @see https://en.wikipedia.org/wiki/MurmurHash
111
+ *
112
+ * @param content - The value to hash
113
+ * @param options - Hashing options
114
+ * @returns A hashed string value
115
+ */
116
+ declare function murmurhash(content: any, options?: HashOptions): string;
117
+ //#endregion
118
+ //#region src/hash-files.d.ts
119
+ /**
120
+ * Hash a list of file paths into a string based on the file content
121
+ *
122
+ * @param files - The list of file paths to hash
123
+ * @param options - Hashing options
124
+ * @returns A hashed string value
125
+ */
126
+ declare function hashFiles(files: string[], options?: HashOptions): Promise<string>;
127
+ /**
128
+ * Hash a folder path into a string based on the file content
129
+ *
130
+ * @param directoryPath - The folder path to hash
131
+ * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
132
+ * @returns A hashed string value
133
+ */
134
+ declare function hashDirectory(directoryPath: string, options?: HashOptions & ListOptions): Promise<string>;
135
+ //#endregion
136
+ //#region src/md5.d.ts
137
+ /**
138
+ * Generate an MD5 hash of the provided content.
139
+ *
140
+ * @param content - The content to hash.
141
+ * @param length - The length of the hash to return.
142
+ * @returns The generated MD5 hash.
143
+ */
144
+ declare function md5(content: string, length?: number): string;
145
+ //#endregion
146
+ //#region src/pbkdf2.d.ts
147
+ /**
148
+ * Hash a password using PBKDF2 (Web Crypto compatible alternative to Argon2) with SHA-256, 100,000 iterations, and a random salt. The resulting hash is formatted as: `$pbkdf2-sha256$iterations$salt$hash`.
149
+ *
150
+ * @remarks
151
+ * This function uses the Web Crypto API to perform password hashing. It generates a random salt for each password, and uses PBKDF2 with SHA-256 and 100,000 iterations to derive a secure hash. The output is a string that includes the algorithm, iteration count, salt, and hash, which can be stored in a database for later verification using the {@link verifyPassword} function.
152
+ *
153
+ * @param password - The password to hash.
154
+ * @returns A promise that resolves to the hashed password string.
155
+ */
156
+ declare function hashPassword(password: string): Promise<string>;
157
+ /**
158
+ * Verify a password against a stored hash in the format produced by {@link hashPassword}.
159
+ *
160
+ * @param password - The password to verify.
161
+ * @param storedHash - The stored hash to verify against.
162
+ * @returns A promise that resolves to true if the password is correct, false otherwise.
163
+ */
164
+ declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
165
+ //#endregion
166
+ //#region src/xx-hash.d.ts
167
+ declare const xxHash32: (s: string) => number;
168
+ declare const xxHash64: (s: string) => bigint;
169
+ declare const xxHash128: (s: string) => bigint;
170
+ //#endregion
171
+ export { AlgorithmIdentifier, HashOptions, Hasher, createHasher, digest, fnv1a52, generateETag, hash, hashContent, hashDirectory, hashFiles, hashPassword, md5, murmurhash, sha256, sha384, sha512, verifyContent, verifyPassword, xxHash128, xxHash32, xxHash64 };
172
+ //# sourceMappingURL=node.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.cts","names":[],"sources":["../src/digest.ts","../src/etag.ts","../src/hash-content.ts","../../fs/src/list-files.ts","../src/murmurhash.ts","../src/hash-files.ts","../src/md5.ts","../src/pbkdf2.ts","../src/xx-hash.ts"],"sourcesContent":[],"mappings":";;;KAoBY,mBAAA;;;AAAZ;AAQA;AAgBA;;AAEa,iBAlBG,YAAA,CAkBH,SAAA,EAlB2B,mBAkB3B,CAAA,EAlBiD,MAkBjD;;;AAiBb;AAQA;AASA;AASA;AAGA;;;;;;iBAhDsB,MAAA,gBACL,wBACJ,sBACV;;;ACpBH;AA2Ca,cDPA,ICWZ,EAAA,ODXgB,MCWhB;;;;AC/CD;AAkBA;;cF0Ba,wBAA+B,eAAU;;AG9CtD;;;;ACLA;AAmBgB,cJyCH,MIzCa,EAAyB,CAAA,IAAA,EAAA,MAAW,GJyClB,UIzCkB,EAAA,GJyCR,OIzCQ,CAAA,MAAA,CAAA;;;;ACR9D;AAqBA;;AAEyB,cLmCZ,MKnCY,E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CAAA,MAAA,CAAA;;;;;;AArF1B;AAQA;AAgBA;;AAEa,iBMnBG,GAAA,CNmBH,OAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;;;AA1Bb;AAQA;AAgBA;;;;AAGU,iBOpBY,YAAA,CPoBZ,QAAA,EAAA,MAAA,CAAA,EOpB4C,OPoB5C,CAAA,MAAA,CAAA;AAgBV;AAQA;AASA;AASA;AAGA;;;AAa0B,iBOzCJ,cAAA,CPyCI,QAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,CAAA,EOtCvB,OPsCuB,CAAA,OAAA,CAAA;;;cQrEb;cACA;cACA"}
@@ -0,0 +1,172 @@
1
+ import { GlobOptions } from "glob";
2
+
3
+ //#region src/digest.d.ts
4
+ type AlgorithmIdentifier = "SHA-256" | "SHA-384" | "SHA-512";
5
+ /**
6
+ * Creates a new hash object for the specified algorithm.
7
+ *
8
+ * @param algorithm - The algorithm to use for the hash.
9
+ * @returns A new hash object.
10
+ */
11
+ declare function createHasher(algorithm: AlgorithmIdentifier): Hasher;
12
+ /**
13
+ * Creates a new hash object for the specified algorithm.
14
+ *
15
+ * @remarks
16
+ * This function uses the Web Crypto API to create a hash of the input data.
17
+ *
18
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
19
+ *
20
+ * @param data - The data to hash.
21
+ * @param algorithm - The algorithm to use for the hash.
22
+ * @returns A hash string representation of the `data` parameter.
23
+ */
24
+ declare function digest(data: string | Uint8Array, algorithm?: AlgorithmIdentifier): Promise<string>;
25
+ /**
26
+ * Alias for {@link digest}.
27
+ */
28
+ declare const hash: typeof digest;
29
+ /**
30
+ * Hash a string or Uint8Array using SHA-256 and return the result as a base64url-encoded string.
31
+ *
32
+ * @param data - The data to hash.
33
+ * @returns A hash string representation of the `data` parameter.
34
+ */
35
+ declare const sha256: (data: string | Uint8Array) => Promise<string>;
36
+ /**
37
+ * Hash a string or Uint8Array using SHA-384 and return the result as a base64url-encoded string.
38
+ *
39
+ * @param data - The data to hash.
40
+ * @returns A hash string representation of the `data` parameter.
41
+ */
42
+ declare const sha384: (data: string | Uint8Array) => Promise<string>;
43
+ /**
44
+ * Hash a string or Uint8Array using SHA-512 and return the result as a base64url-encoded string.
45
+ *
46
+ * @param data - The data to hash.
47
+ * @returns A hash string representation of the `data` parameter.
48
+ */
49
+ declare const sha512: (data: string | Uint8Array) => Promise<string>;
50
+ declare class Hasher {
51
+ #private;
52
+ constructor(algorithm: AlgorithmIdentifier);
53
+ update(data: Uint8Array): void;
54
+ digest(): Promise<Uint8Array>;
55
+ }
56
+ //#endregion
57
+ //#region src/etag.d.ts
58
+ /**
59
+ * FNV-1a Hash implementation
60
+ *
61
+ * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
62
+ *
63
+ * @remarks
64
+ * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
65
+ * and still making use of Javascript's 53-bit integer space.
66
+ */
67
+ declare const fnv1a52: (str: string) => number;
68
+ /**
69
+ * Generates an ETag for the given payload.
70
+ *
71
+ * @param payload - The payload to generate an ETag for.
72
+ * @param weak - Whether to generate a weak ETag.
73
+ * @returns The generated ETag.
74
+ */
75
+ declare const generateETag: (payload: string, weak?: boolean) => string;
76
+ //#endregion
77
+ //#region src/hash-content.d.ts
78
+ /**
79
+ * Hash the content of a PDU (Protocol Data Unit) by removing the `signatures` and `unsigned` fields, then hashing the remaining content using SHA-256 and encoding it as a base64url string. This function is useful for generating a consistent hash of the PDU content that can be used for integrity verification or caching purposes, while ignoring any fields that may change due to signatures or unsigned data.
80
+ *
81
+ * @param content - The PDU content to hash, represented as a record of string keys and unknown values.
82
+ * @returns A promise that resolves to a base64url-encoded string representing the hash of the PDU content.
83
+ */
84
+ declare function hashContent(content: Record<string, unknown>): Promise<string>;
85
+ /**
86
+ * Verify the hash of a PDU (Protocol Data Unit) content by hashing the content using the {@link hashContent} function and comparing it to an expected hash value. This function is useful for validating the integrity of the PDU content by ensuring that the computed hash matches the expected hash, which can be used to detect any tampering or corruption of the content.
87
+ *
88
+ * @param content - The PDU content to verify, represented as a record of string keys and unknown values.
89
+ * @param expectedHash - The expected hash value to compare against, represented as a string.
90
+ * @returns A promise that resolves to a boolean indicating whether the computed hash of the content matches the expected hash value (true if they match, false otherwise).
91
+ */
92
+ declare function verifyContent(content: Record<string, unknown>, expectedHash: string): Promise<boolean>;
93
+ //#endregion
94
+ //#region ../fs/src/list-files.d.ts
95
+ type ListOptions = GlobOptions;
96
+ //#endregion
97
+ //#region src/murmurhash.d.ts
98
+ interface HashOptions {
99
+ /**
100
+ * The maximum length of the hash
101
+ *
102
+ * @defaultValue 32
103
+ */
104
+ maxLength?: number;
105
+ }
106
+ /**
107
+ * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.
108
+ *
109
+ * @see https://github.com/ohash/ohash
110
+ * @see https://en.wikipedia.org/wiki/MurmurHash
111
+ *
112
+ * @param content - The value to hash
113
+ * @param options - Hashing options
114
+ * @returns A hashed string value
115
+ */
116
+ declare function murmurhash(content: any, options?: HashOptions): string;
117
+ //#endregion
118
+ //#region src/hash-files.d.ts
119
+ /**
120
+ * Hash a list of file paths into a string based on the file content
121
+ *
122
+ * @param files - The list of file paths to hash
123
+ * @param options - Hashing options
124
+ * @returns A hashed string value
125
+ */
126
+ declare function hashFiles(files: string[], options?: HashOptions): Promise<string>;
127
+ /**
128
+ * Hash a folder path into a string based on the file content
129
+ *
130
+ * @param directoryPath - The folder path to hash
131
+ * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
132
+ * @returns A hashed string value
133
+ */
134
+ declare function hashDirectory(directoryPath: string, options?: HashOptions & ListOptions): Promise<string>;
135
+ //#endregion
136
+ //#region src/md5.d.ts
137
+ /**
138
+ * Generate an MD5 hash of the provided content.
139
+ *
140
+ * @param content - The content to hash.
141
+ * @param length - The length of the hash to return.
142
+ * @returns The generated MD5 hash.
143
+ */
144
+ declare function md5(content: string, length?: number): string;
145
+ //#endregion
146
+ //#region src/pbkdf2.d.ts
147
+ /**
148
+ * Hash a password using PBKDF2 (Web Crypto compatible alternative to Argon2) with SHA-256, 100,000 iterations, and a random salt. The resulting hash is formatted as: `$pbkdf2-sha256$iterations$salt$hash`.
149
+ *
150
+ * @remarks
151
+ * This function uses the Web Crypto API to perform password hashing. It generates a random salt for each password, and uses PBKDF2 with SHA-256 and 100,000 iterations to derive a secure hash. The output is a string that includes the algorithm, iteration count, salt, and hash, which can be stored in a database for later verification using the {@link verifyPassword} function.
152
+ *
153
+ * @param password - The password to hash.
154
+ * @returns A promise that resolves to the hashed password string.
155
+ */
156
+ declare function hashPassword(password: string): Promise<string>;
157
+ /**
158
+ * Verify a password against a stored hash in the format produced by {@link hashPassword}.
159
+ *
160
+ * @param password - The password to verify.
161
+ * @param storedHash - The stored hash to verify against.
162
+ * @returns A promise that resolves to true if the password is correct, false otherwise.
163
+ */
164
+ declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
165
+ //#endregion
166
+ //#region src/xx-hash.d.ts
167
+ declare const xxHash32: (s: string) => number;
168
+ declare const xxHash64: (s: string) => bigint;
169
+ declare const xxHash128: (s: string) => bigint;
170
+ //#endregion
171
+ export { AlgorithmIdentifier, HashOptions, Hasher, createHasher, digest, fnv1a52, generateETag, hash, hashContent, hashDirectory, hashFiles, hashPassword, md5, murmurhash, sha256, sha384, sha512, verifyContent, verifyPassword, xxHash128, xxHash32, xxHash64 };
172
+ //# sourceMappingURL=node.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.mts","names":[],"sources":["../src/digest.ts","../src/etag.ts","../src/hash-content.ts","../../fs/src/list-files.ts","../src/murmurhash.ts","../src/hash-files.ts","../src/md5.ts","../src/pbkdf2.ts","../src/xx-hash.ts"],"sourcesContent":[],"mappings":";;;KAoBY,mBAAA;;;AAAZ;AAQA;AAgBA;;AAEa,iBAlBG,YAAA,CAkBH,SA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