• options {Object} [stream.transform options][]
    • Returns: {Hash}

    Creates a new Hash object that contains a deep copy of the internal state of the current Hash object.

    The optional options argument controls stream behavior. For XOF hash functions such as 'shake256', the outputLength option can be used to specify the desired output length in bytes.

    An error is thrown when an attempt is made to copy the Hash object after its [hash.digest()][] method has been called.

    1. // Calculate a rolling hash.
    2. const crypto = require('crypto');
    3. const hash = crypto.createHash('sha256');
    4. hash.update('one');
    5. console.log(hash.copy().digest('hex'));
    6. hash.update('two');
    7. console.log(hash.copy().digest('hex'));
    8. hash.update('three');
    9. console.log(hash.copy().digest('hex'));
    10. // Etc.