I am building an application which have the paid tutorials videos. The videos are not hosted on any kind of server instead they are part of my application bundle. I want to make sure that those videos cannot be extracted from my bundle. Can I use the RNCryptor to encrypt the videos and in the application and decrypt only while playing?Please guide me if some one knows any good method for encryption in my case.
--
You received this message because you are subscribed to the Google Groups "rncryptor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rncryptor+...@googlegroups.com.
Visit this group at https://groups.google.com/group/rncryptor.
For more options, visit https://groups.google.com/d/optout.
// somewhere in your code, probably -viewDidLoad:
NSURL *dummyURL = [NSURL URLWithString:@"somethingfunny://dummy.mov"];// a non-reachable URL will force the use of the resourceLoader delegate
AVURLAsset *asset = [AVURLAsset assetWithURL:dummyURL];
[asset.resourceLoader setDelegate:self queue:dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0)];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
self.avPlayerVC.player = [AVPlayer playerWithPlayerItem:item];
[self.avPlayerVC.player play];
//
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest {
loadingRequest.contentInformationRequest.contentType = [NSString ut_UTTypeQuickTimeMovie];
loadingRequest.contentInformationRequest.contentLength = self.doc.decryptedAsset.length;
loadingRequest.contentInformationRequest.byteRangeAccessSupported = YES;
NSRange range = NSMakeRange((NSUInteger)loadingRequest.dataRequest.requestedOffset, loadingRequest.dataRequest.requestedLength);
[loadingRequest.dataRequest respondWithData:[self.doc.decryptedAsset subdataWithRange:range]];
[loadingRequest finishLoading];
return YES;
}
// in your model class:
// cache decrypted data, otherwise memory consumption would be 4x the asset size
- (NSData *)decryptedAsset {
if (!self.asset.fileURL) {
[_errh logMessage:@"Warning: nil asset" object:self alertUser:NO];
return nil;
} else if (!_decryptedAsset) {
TSCryptoKeys *ckeys = [TSCryptoKeys userCryptoKeys];
NSError *error;
// by using the NSDataReadingMappedAlways option the property doesn't consume any memory at all
// decryption itself appears to be consuming 2x asset size memory once
NSData *encData = [NSData dataWithContentsOfURL:self.asset.fileURL options:NSDataReadingMappedAlways error:&error];
[_errh handleError:error];
_decryptedAsset = [ckeys decryptData:encData];
}
return _decryptedAsset;
}