encrypt method

String encrypt(
  1. String plaintext
)

Implementation

String encrypt(String plaintext) {
  final units = utf8.encode(plaintext);
  final outLen = olm_group_encrypt_message_length(_inst, units.length);
  final mem = malloc.call<Uint8>(units.length + outLen);
  final outMem = mem.elementAt(units.length);
  try {
    mem.asTypedList(units.length).setAll(0, units);
    olm_group_encrypt(_inst, mem, units.length, outMem, outLen);
    return utf8.decode(outMem.asTypedList(outLen));
  } finally {
    malloc.free(mem);
  }
}