encryptFileFromPath method

String encryptFileFromPath(
  1. String clearFilePath
)

Encrypt a clear-text file into an encrypted file, for the recipients of this session.

clearFilePath - The path of the file to encrypt. Returns the path of the encrypted file.

Implementation

String encryptFileFromPath(String clearFilePath) {
  final Pointer<Utf8> nativeClearFilePath = clearFilePath.toNativeUtf8();
  final Pointer<Pointer<Utf8>> result = calloc<Pointer<Utf8>>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode = _bindings.SealdEncryptionSession_EncryptFileFromPath(
      _ptr.pointer(), nativeClearFilePath, result, err);

  calloc.free(nativeClearFilePath);

  if (resultCode != 0) {
    calloc.free(result);
    throw SealdException._fromCPtr(err);
  } else {
    final String encryptedFilePath = result.value.toDartString();
    calloc.free(result.value);
    calloc.free(result);
    calloc.free(err);
    return encryptedFilePath;
  }
}