dartrosa_encryption 0.1.1 copy "dartrosa_encryption: ^0.1.1" to clipboard
dartrosa_encryption: ^0.1.1 copied to clipboard

Encrypted ODK submissions for DartRosa: a port of ODK Collect's EncryptionUtils, decryptable by ODK Central and ODK Briefcase.

dartrosa_encryption #

pub package pub points CI License: Apache-2.0

Encrypted ODK submissions for DartRosa: a port of ODK Collect's EncryptionUtils.

When a form's <submission> has a base64RsaPublicKey, the submission XML and its attachments are encrypted with a random AES key (itself RSA-OAEP encrypted with the form's key) and replaced by a plaintext manifest carrying the encrypted key and an element signature. The output is byte-compatible with what ODK Collect produces, so ODK Central and ODK Briefcase decrypt it. Pure Dart (pointycastle), works on the web.

Install #

dart pub add dartrosa_encryption

Example #

import 'dart:convert';

import 'package:dartrosa/dartrosa.dart';
import 'package:dartrosa_encryption/dartrosa_encryption.dart';

Future<void> main() async {
  final definition = await FormDefinition.parse(encryptedFormXml);
  final session = definition.createSession();
  // ... answer questions ...
  if (session.finalize() case FinalizeSuccess(:final submission)) {
    final encrypted = encryptSubmission(
      utf8.encode(submission.xml),
      {'photo.jpg': photoBytes}, // attachments: file name -> bytes
      definition.formDef,
    );
    if (encrypted != null) {
      // Upload encrypted.manifestBytes as xml_submission_file and
      // encrypted.encryptedFiles (submission.xml.enc, photo.jpg.enc).
    }
  }
}

encryptSubmission returns null for forms that aren't encrypted. See example/example.dart for a runnable program; dartrosa_openrosa's InstanceUpload.forForm does this automatically when uploading.

Documentation #

License #

Apache License 2.0 (see LICENSE). Ports ODK Collect's EncryptionUtils (Apache-2.0); see the licensing notes.

0
likes
160
points
383
downloads

Documentation

API reference

Publisher

verified publishersudhi.in

Weekly Downloads

Encrypted ODK submissions for DartRosa: a port of ODK Collect's EncryptionUtils, decryptable by ODK Central and ODK Briefcase.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#odk #xforms #encryption #data-collection #form

License

Apache-2.0 (license)

Dependencies

crypto, dartrosa, pointycastle

More

Packages that depend on dartrosa_encryption