I have encrypted the video file(.mov) using RNCryptor Library after downloading the file. Now I want to play this video file using AVPlayer. When I decrypt the file it returns NSData. How I can play that video using NSData in AVPlayer.
for encryption I have added following code:-
let fm = FileManager.default
guard let docUrl = fm.urls(for: .documentDirectory, in: .userDomainMask).first else {
print("Unable to reach the documents folder")
return
}
let localUrl = docUrl.appendingPathComponent(String.init(format: "%@", downloadModel.fileName))
let data = try Data.init(contentsOf: localUrl)
let password = "secret"
let cipherText = RNCryptor.encrypt(data: data, withPassword: password)
for decryption of video file
let cipherText = UserDefaults.sharedInstance.getCipherText()
// Decryption
do {
let originalData = try RNCryptor.decrypt(data: cipherText, withPassword: "secret")
debugPrint(originalData)
let dataString = String.init(data: originalData, encoding: .utf16)
let url = URL.init(string: dataString!)
configureVideoPlayer(url: url!)
} catch {
print(error)
}
but url is nil. How I can achieve this.