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.

  • Parameters
    • String text - Text to be locked.
    • Callback success - Success block to be executed after text is successfully locked, returns locked text through key "lockedText".
    • Callback failure - Failure block to be executed if locking fails, returns BayunError.
String plainText; bayunCore.lockText(plainText, success, failure); // Callbacks for locking text success = new Handler.Callback() { @Override public boolean handleMessage(Message message) { String lockedText = message.getData().getString("lockedText", ""); return false; } } failure = new Handler.Callback() { @Override public boolean handleMessage(Message message) { String error = message.getData().getString("BayunError"); if (response.equalsIgnoreCase(BayunError.ERROR_INTERNET_CONNECTION)) { } else if (response.equalsIgnoreCase(BayunError.ERROR_ENCRYPTION_FAILED)) { } return false; } };

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.

  • Parameters
    • String text - Text to be locked.
    • int encryptionPolicy - BayunEncryptionPolicy determines the key for locking.
    • int keyGenerationPolicy - BayunKeyGenerationPolicy determines the policy to generate the data encryption key.
    • String groupId - GroupId is required if encryptionPolicy is BayunEncryptionPolicyGroup.
    • Callback success - Success block to be executed after text is successfully locked, returns locked text through key "lockedText".
    • Callback failure - Failure block to be executed if locking fails, returns BayunError.
byte plaintext; int encryptionPolicy = BayunCore.ENCRYPTION_POLICY_COMPANY; int keyGenerationPolicy = BayunCore.KEY_GENERATION_POLICY_ENVELOPE; String groupId; bayunCore.lockText(plaintext, encryptionPolicy, keyGenerationPolicy, groupId, success, failure); // Callbacks for locking text success = new Handler.Callback() { @Override public boolean handleMessage(Message message) { String lockedText = message.getData().getString("lockedText", ""); return false; } } failure = new Handler.Callback() { @Override public boolean handleMessage(Message message) { String error = message.getData().getString("BayunError"); if (response.equalsIgnoreCase(BayunError.ERROR_INTERNET_CONNECTION)) { } else if (response.equalsIgnoreCase(BayunError.ERROR_ENCRYPTION_FAILED)) { } return false; } };
Note : If encryption-policy is other than BayunEncryptionPolicyGroup then groupId should be nil.

5.2.3 Unlock Text

The unlockText method of BayunCore class unlocks text.

  • Parameters
    • String text - Text to be unlocked.
    • Callback success - Success block to be executed after text is successfully unlocked, returns unlocked text through key "unlockedText".
    • Callback failure - Failure block to be executed if unlocking fails, returns BayunError.
String lockedText; bayunCore.unlockText(lockedText, success, failure); // Callbacks for unlocking text success = new Handler.Callback() { @Override public boolean handleMessage(Message message) { String unlockedText = message.getData().getString("unlockedText", ""); return false; } } failure = new Handler.Callback() { @Override public boolean handleMessage(Message message) { String error = message.getData().getString("BayunError"); if (response.equalsIgnoreCase(BayunError.ERROR_INTERNET_CONNECTION)) { } else if (response.equalsIgnoreCase(BayunError.ERROR_DECRYPTION_FAILED)) { } return false; } };

results matching ""

    No results matching ""