encryptJson = (data, key) => {
  const dataEncoder = encoding.createEncoder();
  encoding.writeAny(dataEncoder, data);
  return encrypt(encoding.toUint8Array(dataEncoder), key);
}
@param {Object} data data to be encrypted
@param {CryptoKey?} key
@return {PromiseLike<Uint8Array>} encrypted data, if key is provided