Use Encripted File
The use of encrypted materials in the PAG Enterprise SDK requires a decryption certificate. For how to encrypt and decrypt materials, refer to File Encryption.
PAGLicenseManager only allows certificates to be added through paths or file data. It is highly recommended to generate encryption certificates in the background to avoid any issues with expired local certificates that could lead to loading failures. The decryption certificate can be loaded when calling the PAG SDK. If the application remains open, there is no need to add the encrypted file again for subsequent loading.
Android
/**
* To ensure successful loading of encrypted material, it is crucial to include a material certificate. Failure to do so will result in a nil return. It is highly recommended to add the certificate immediately after launching the APP to prevent any rendered encrypted material from becoming unusable
*/
private void initFileLicense() {
int result = PAGLicenseManager.AddFileLicense(applicationContext, SDK_LICENSE_FILE_PATH);
if (result == PAGLicenseManager.LicenseResultSuccess) {
Log.i(TAG, "PAGLicenseManager.AddFileLicense success");
} else {
Log.i(TAG, "PAGLicenseManager.AddFileLicense failed");
}
}
/**
* Encrypted files can be loaded just like regular files, without the need for additional interfaces. If a file fails to load, it could be due to the absence of the decryption certificate for the content or an incorrect file structure. To check the file status, you can use the PAGViewer function on your desktop.
*/
private void loadEncryptedFile() {
PAGFile pagFile = PAGFile.Load(PAG_FILE_PATH);
if (pagFile == null) {
Log.i(TAG, "PAGFile.Load failed");
} else {
Log.i(TAG, "PAGFile.Load success");
}
}
iOS
/**
* To ensure successful loading of encrypted material, it is crucial to include a material certificate. Failure to do so will result in a nil return. It is highly recommended to add the certificate immediately after launching the APP to prevent any rendered encrypted material from becoming unusable.
*/
- (void)initFileLicense {
NSString *path = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"license"];
PAGLicenseResult result = [PAGLicenseManager AddFileLicense:path];
if (result == PAGLicenseResultSuccess) {
NSLog(@"Successfully added license.");
} else {
NSLog(@"Failed to add certificate. Path:%@", path);
}
}
/**
* Encrypted files can be loaded just like regular files, without the need for additional interfaces. If a file fails to load, it could be due to the absence of the decryption certificate for the content or an incorrect file structure. To check the file status, you can use the PAGViewer function on your desktop.
*/
- (void)loadEncryptedFile {
NSString *path = [[NSBundle mainBundle] pathForResource:@"encryptedFile" ofType:@"pag"];
PAGFile *file = [PAGFile Load:path];
}