* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding} * @param {string=} encoding encoding of the return value * @returns {string | Buffer} digest
(encoding)
| 197 | * @returns {string | Buffer} digest |
| 198 | */ |
| 199 | digest(encoding) { |
| 200 | const { exports, buffered, mem, digestSize } = this; |
| 201 | exports.final(buffered); |
| 202 | this.instancesPool.push(this); |
| 203 | const hex = mem.toString("latin1", 0, digestSize); |
| 204 | if (encoding === "hex") return hex; |
| 205 | if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex"); |
| 206 | return Buffer.from(hex, "hex").toString( |
| 207 | /** @type {NodeJS.BufferEncoding} */ (encoding) |
| 208 | ); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** |