5.3 Data Locking/Unlocking

5.3.1 Lock Data

The lockData method of BayunCore class locks NSData with default encryption-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.

Objective-C
Swift 3.0

[[BayunCore sharedInstance] lockData:data success:^(NSData *lockedData) {
    NSLog(@"Data locked successfully.");   
} failure:^(BayunError errorCode) {
    NSLog(@"Error locking data.");    
}];

BayunCore.sharedInstance().lockData(data, success: { (lockedData) in
   NSLog("Data locked successfully.");                    
}, failure: { (bayunError) in
   NSLog("Error locking data.");
})

5.3.2 Lock Data with encryption-policy

The lockData 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.
Note : If encryption-policy is other than BayunEncryptionPolicyGroup then groupId should be nil.

Objective-C
Swift 3.0

[[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.");
}];


BayunCore.sharedInstance().lockData(data, encryptionPolicy: .company, groupId: nil, success: { (lockedText) in
    NSLog("Text locked successfully.")         
}, failure: { (bayunErrorCode) in
    NSLog("Error locking data.");            
})

5.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.

Objective-C
Swift 3.0

[[BayunCore sharedInstance] unlockData:lockedData success:^(NSData *unlockedData) {
    NSLog(@"Data unlocked successfully.");  
} failure:^(BayunError errorCode) {
    NSLog(@"Error unlocking data.");    
}];

BayunCore.sharedInstance().unlockData(lockedData, success: { (unlockedData) in
    NSLog("Data unlocked successfully.")
 }, failure: { (bayunError) in
    NSLog("Error unlocking data.")                
 })

results matching ""

    No results matching ""