decrypt method

String decrypt(
  1. int message_type,
  2. String message
)

Implementation

String decrypt(int message_type, String message) {
  final units = utf8.encode(message);
  final mem = malloc.call<Uint8>(units.length);
  try {
    mem.asTypedList(units.length).setAll(0, units);
    int outLen = olm_decrypt_max_plaintext_length(
        _inst, message_type, mem, units.length);
    mem.asTypedList(units.length).setAll(0, units);
    final outMem = malloc.call<Uint8>(outLen);
    try {
      outLen =
          olm_decrypt(_inst, message_type, mem, units.length, outMem, outLen);
      return utf8.decode(outMem.asTypedList(outLen));
    } finally {
      malloc.free(outMem);
    }
  } finally {
    malloc.free(mem);
  }
}