lib/crypto/crypto-engine.js
function hmacSha256(key, data) {
    if (subtle) {
        var algo = { name: 'HMAC', hash: { name: 'SHA-256' } };
        return subtle.importKey('raw', key, algo, false, ['sign'])
            .then(function(subtleKey) {
                return subtle.sign(algo, subtleKey, data);
            });
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key));
            var hash = hmac.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'HMAC-SHA256 not implemented'));
    }
}
function hmacSha256(key, data) {
    if (subtle) {
        var algo = { name: 'HMAC', hash: { name: 'SHA-256' } };
        return subtle.importKey('raw', key, algo, false, ['sign'])
            .then(function(subtleKey) {
                return subtle.sign(algo, subtleKey, data);
            });
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key));
            var hash = hmac.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'HMAC-SHA256 not implemented'));
    }
}
function hmacSha256 ( key , data ) { if ( subtle ) { var algo = { name : 'HMAC' , hash : { name : 'SHA-256' } } ; return subtle . importKey ( 'raw' , key , algo , false , [ 'sign' ] ) . then ( function ( subtleKey ) { return subtle . sign ( algo , subtleKey , data ) ; } ) ; } else if ( nodeCrypto ) { return new Promise ( function ( resolve ) { var hmac = nodeCrypto . createHmac ( 'sha256' , Buffer . from ( key ) ) ; var hash = hmac . update ( Buffer . from ( data ) ) . digest ( ) ; resolve ( hash . buffer ) ; } ) ; } else { return Promise . reject ( new KdbxError ( Consts . ErrorCodes . NotImplemented , 'HMAC-SHA256 not implemented' ) ) ; } }
HMAC-SHA-256 hash
@param {ArrayBuffer} key
@param {ArrayBuffer} data
@returns {Promise.<ArrayBuffer>}
HMAC - SHA - 256 hash