toXml method

  1. @override
XMLNode toXml()
override

Turn the source into an XML element.

Implementation

@override
XMLNode toXml() {
  return XMLNode.xmlns(
    tag: 'encrypted',
    xmlns: sfsEncryptionXmlns,
    attributes: <String, String>{
      'cipher': encryption.toNamespace(),
    },
    children: [
      XMLNode(
        tag: 'key',
        text: base64Encode(key),
      ),
      XMLNode(
        tag: 'iv',
        text: base64Encode(iv),
      ),
      ...hashes.entries
          .map((hash) => constructHashElement(hash.key, hash.value)),
      XMLNode.xmlns(
        tag: 'sources',
        xmlns: sfsXmlns,
        children: [source.toXml()],
      ),
    ],
  );
}