code: function decrypt(data) {
      return Promise.resolve().then(function() {
          var stm = new BinaryStream(data);
          var buffers = [];
          var blockIndex = 0, blockLength = 0, blockHash, totalLength = 0;
  
          var next = function() {
              blockIndex = stm.getUint32(true);
              blockHash = stm.readBytes(32);
              blockLength = stm.getUint32(true);
              if (blockLength > 0) {
                  totalLength += blockLength;
                  var blockData = stm.readBytes(blockLength);
                  return CryptoEngine.sha256(blockData).then(function(calculatedHash) {
                      if (!ByteUtils.arrayBufferEquals(calculatedHash, blockHash)) {
                          throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'invalid hash block');
                      } else {
                          buffers.push(blockData);
                          return next();
                      }
                  });
              } else {
                  var ret = new Uint8Array(totalLength);
                  var offset = 0;
                  for (var i = 0; i < buffers.length; i++) {
                      ret.set(new Uint8Array(buffers[i]), offset);
                      offset += buffers[i].byteLength;
                  }
                  return ret.buffer;
              }
          };
          return next();
      });
  }
docs: Decrypt buffer
  @param {ArrayBuffer} data
  @returns {Promise.<ArrayBuffer>}