6.3 Lock/Unlock Data
6.3.1 Lock Data
The lockData:success:failure
method of BayunCore
class locks NSData with default encryption-policy
and key-generation-policy
dictated by server settings.
Method parameters :
data : Data to be locked.
dataType :
NSData
success : Success block to be executed after data is successfully locked, returns locked data.
failure : Failure block to be executed if locking fails, returns
BayunError
.
NSData *data = [[NSData alloc] initWithContentsOfFile:@"<FileName.txt>"];
[[BayunCore sharedInstance] lockData:data success:^(NSData *lockedData) {
NSLog(@"Data locked successfully.");
} failure:^(BayunError errorCode) {
NSLog(@"Error locking data.");
}];
6.3.2 Lock Data with Encryption Policy, Key Generation Policy
The lockData:encryptionPolicy:keyGenerationPolicy:groupId:success:failure
method with encryption-policy as an optional parameter locks data with the encryption key dictated by the policy. The method takes the following parameters :
text : Data to be locked.
dataType :
NSData
encryptionPolicy : BayunEncryptionPolicy determines the key for locking.
keyGenerationPolicy : BayunKeyGenerationPolicy determines the policy to generate the data encryption key.
groupId : GroupId is required if encryptionPolicy is
BayunEncryptionPolicyGroup
.success : Success block to be executed after data is successfully locked, returns locked data.
failure : Failure block to be executed if locking fails, returns
BayunError
.
[[BayunCore sharedInstance] lockData:data
encryptionPolicy:encryptionPolicy
keyGenerationPolicy:(BayunKeyGenerationPolicy)keyGenerationPolicy
groupId:groupId
success:^(NSString *lockedText)
NSLog("Data locked successfully.") ;
} failure:^(BayunError errorCode) {
NSLog(@"Error locking data.");
}];
6.3.3 Unlock Data
The unlockData
method of BayunCore
class unlocks a locked NSData. The method takes the following parameters :
data : Data to be unlocked.
dataType :
NSData
success : Success block to be executed after data is successfuly unlocked, returns unlocked data.
failure : Failure block to be executed if unlocking fails, returns
BayunError
.
[[BayunCore sharedInstance] unlockData:lockedData success:^(NSData *unlockedData) {
NSLog(@"Data unlocked successfully.");
} failure:^(BayunError errorCode) {
NSLog(@"Error unlocking data.");
}];
Last updated
Was this helpful?