lib/crypto/crypto-engine.js
function sha256(data) {
    if (!data.byteLength) {
        return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));
    }
    if (subtle) {
        return subtle.digest({ name: 'SHA-256' }, data);
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var sha = nodeCrypto.createHash('sha256');
            var hash = sha.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));
    }
}
function sha256(data) {
    if (!data.byteLength) {
        return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));
    }
    if (subtle) {
        return subtle.digest({ name: 'SHA-256' }, data);
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var sha = nodeCrypto.createHash('sha256');
            var hash = sha.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));
    }
}
function sha256 ( data ) { if ( ! data . byteLength ) { return Promise . resolve ( ByteUtils . arrayToBuffer ( ByteUtils . hexToBytes ( EmptySha256 ) ) ) ; } if ( subtle ) { return subtle . digest ( { name : 'SHA-256' } , data ) ; } else if ( nodeCrypto ) { return new Promise ( function ( resolve ) { var sha = nodeCrypto . createHash ( 'sha256' ) ; var hash = sha . update ( Buffer . from ( data ) ) . digest ( ) ; resolve ( hash . buffer ) ; } ) ; } else { return Promise . reject ( new KdbxError ( Consts . ErrorCodes . NotImplemented , 'SHA256 not implemented' ) ) ; } }
SHA-256 hash
@param {ArrayBuffer} data
@returns {Promise.<ArrayBuffer>}
SHA - 256 hash