decryptFileFromPath method
Decrypts an encrypted file into the corresponding clear-text file.
encryptedFilePath
- The path of the encrypted file to decrypt.
Returns the path of the decrypted file.
Implementation
String decryptFileFromPath(String encryptedFilePath) {
final Pointer<Utf8> nativeEncryptedFilePath =
encryptedFilePath.toNativeUtf8();
final Pointer<Pointer<Utf8>> result = calloc<Pointer<Utf8>>();
final Pointer<Pointer<NativeSealdError>> err =
calloc<Pointer<NativeSealdError>>();
final int resultCode = _bindings.SealdEncryptionSession_DecryptFileFromPath(
_ptr.pointer(), nativeEncryptedFilePath, result, err);
calloc.free(nativeEncryptedFilePath);
if (resultCode != 0) {
calloc.free(result);
throw SealdException._fromCPtr(err);
} else {
final String decryptedFilePath = result.value.toDartString();
calloc.free(result.value);
calloc.free(result);
calloc.free(err);
return decryptedFilePath;
}
}