encryptSymmetricString function

String encryptSymmetricString(
  1. String message,
  2. String passphrase

Encrypts the given message with the given passphrase using SecretBox and returns a base64 encoded buffer containing nonce[24] + cipherText[]. The 24 first bytes represent the nonce, and the rest of the buffer contains the cipher text. The 16 first bytes of the cipher text (containing zeroes) are trimmed out


String encryptSymmetricString(String message, String passphrase) {
  if (bridge.nativeDvote == null)
    throw Exception("The library is not initialized");
  final messagePtr = Utf8.toUtf8(message);
  final passphrasePtr = Utf8.toUtf8(passphrase);

  // The actual native call
  final resultPtr = bridge.encryptSymmetric(messagePtr, passphrasePtr);

  return bridge.handleResultStringPointer(resultPtr);