5.2 Text Locking/Unlocking

5.2.1 Lock Text

The lockText method of BayunCore class locks text with default encryption-policy dictated by server settings.

Method parameters :
  • text : Text to be locked.
    • dataType : NSString
  • success : Success block to be executed after text is successfully locked, returns locked text.
  • failure : Failure block to be executed if locking fails, returns BayunError.

Objective-C
Swift 3.0

[[BayunCore sharedInstance] lockText:@"plain text" success:^(NSString *lockedText) {
    NSLog(@"Text locked successfully.");
} failure:^(BayunError errorCode) {
    NSLog(@"Error locking text.");
}];

BayunCore .sharedInstance().lockText("plain text", success: { (lockedText) in
    NSLog("Text locked successfully.")
 }, failure:  { (bayunErrorCode) in
    NSLog("Error locking text.");
 })

5.2.2 Lock Text with encryption-policy

The lockText method with encryption-policy as an optional parameter locks text with the encryption key dictated by the policy. The method takes the following parameters :

  • text : Text to be locked.
    • dataType : NSString
  • 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 text is successfully locked, returns locked text.
  • 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] lockText:@"plain text"
                    encryptionPolicy:encryptionPolicy
                 keyGenerationPolicy:(BayunKeyGenerationPolicy)keyGenerationPolicy
                             groupId:groupId
                             success:^(NSString *lockedText)
      NSLog("Text locked successfully.") ;                   
} failure:^(BayunError errorCode) {
      NSLog(@"Error locking text.");
}];


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

5.2.3 Unlock Text

The unlockText method of BayunCore class unlocks a locked text. The method takes the following parameters :

  • text : Text to be unlocked.
    • dataType : NSString
  • success : Success block to be executed after text is successfully unlocked, returns unlocked text.
  • failure : Failure block to be executed if unlocking fails, returns BayunError.

Objective-C
Swift 3.0

[[BayunCore sharedInstance] unlockText:@"locked text" success:^(NSString *unlockedText) {
    NSLog(@"Text unlocked successfully.");
} failure:^(BayunError errorCode) {
    NSLog(@"Error unlocking text.");
}];

BayunCore.sharedInstance().unlockText("lockedText", success: { (unlockedText) in
    NSLog("Text unlocked successfully.")
}, failure: { (bayunErrorCode) in
    NSLog("Error unlocking text.")
})

results matching ""

    No results matching ""