6.2 Lock/Unlock Text

6.2.1 Lock Text

The lockText:success:failure method of BayunCore class locks text with default encryption-policy and key-generation-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.

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

6.2.2 Lock Text with Encryption Policy, Key Generation Policy

The lockText:encryptionPolicy:keyGenerationPolicy:groupId:success:failure 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.

If encryption-policy is other than BayunEncryptionPolicyGroup then groupId should be nil.

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

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

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

Last updated