diff --git a/package.json b/package.json index adb9150..9a48c85 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "url": "https://github.com/NaturalCycles/nodejs-lib" }, "engines": { - "node": ">=18.12.0" + "node": ">=20.12.0" }, "description": "Standard library for Node.js", "author": "Natural Cycles Team", diff --git a/src/security/hash.util.ts b/src/security/hash.util.ts index 5845fbb..eab21d3 100644 --- a/src/security/hash.util.ts +++ b/src/security/hash.util.ts @@ -22,24 +22,14 @@ export function hash( algorithm: string, outputEncoding: BinaryToTextEncoding = 'hex', ): string { - // todo: cleanup after @types/node is updated // https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#crypto-implement-cryptohash - // Node 20.12+ - if ((crypto as any).hash) { - return (crypto as any).hash(algorithm, s, outputEncoding) - } - - return crypto.createHash(algorithm).update(s).digest(outputEncoding) + // Note: crypto.hash is Node 20.12+ + return crypto.hash(algorithm, s, outputEncoding) } export function hashAsBuffer(s: string | Buffer, algorithm: string): Buffer { - // todo: cleanup after @types/node is updated - // Node 20.12+ - if ((crypto as any).hash) { - return (crypto as any).hash(algorithm, s, 'buffer') - } - - return crypto.createHash(algorithm).update(s).digest() + // Note: crypto.hash is Node 20.12+ + return crypto.hash(algorithm, s, 'buffer') } export function base64(s: string | Buffer): Base64String {