philcockfield / file-system-cache

A super-fast, promise based cache that reads and writes to the file-system.
MIT License
54 stars 14 forks source link

Choice of Hash Function #29

Closed philcockfield closed 1 year ago

philcockfield commented 1 year ago

Issue: #23

const cache1 = new FileSystemCache();                    // ← default: "sha1"
const cache2 = new FileSystemCache({ hash: 'sha256' });
const cache3 = new FileSystemCache({ hash: 'sha512' });
philcockfield commented 1 year ago

@trevor-vaughan I've added a sha256 and sha512 options.

export type HashAlgorithm = 'sha1' | 'sha256' | 'sha512';

I wonder, are there any other baseline/standard algorithms you'd like to see included?

    const cache1 = new FileSystemCache();                    // ← default: "sha1"
    const cache2 = new FileSystemCache({ hash: 'sha256' });
    const cache3 = new FileSystemCache({ hash: 'sha512' });

Please let me know if you want any others, and I'll get them in and tested, and then bump this feature release over to NPM. Thanks!

trevor-vaughan commented 1 year ago

@philcockfield Ideally, you'd pull the available hashes out of the underlying installation and allow for any from that list.

crypto = require('crypto')
hashes = crypto.getHashes()
philcockfield commented 1 year ago

that's better @trevor-vaughan - cheers!

philcockfield commented 1 year ago

Published as 2.4.0