dartrosa_encryption 0.1.1
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 #
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 #
- API reference
- Documentation index
- Download forms, encrypt and submit
- Getting started
- Compatibility matrix
- Plugins and extension points
- Migrating from JavaRosa
License #
Apache License 2.0 (see LICENSE). Ports ODK Collect's
EncryptionUtils (Apache-2.0); see
the licensing notes.