5.3 Data Locking/Unlocking

5.3.1 Lock Data

The lockData method of BayunCore class locks generic data of type byteArray.

  • Parameters
    • byte[] data - Byte data to be locked.
    • Callback success - Success block to be executed after data is successfully locked, returns locked data through key "lockedData".
    • Callback failure - Failure block to be executed if locking fails, returns BayunError.
byte plainData[]; bayunCore.lockData(plainData, success, failure); // Callbacks for locking data success = new Handler.Callback() { @Override public boolean handleMessage(Message message) { byte[] lockedText = message.getData().getByteArray("lockedData", ""); 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.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.

  • Parameters
    • byte[] data - Byte data 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 data is successfully locked, returns locked data through key "lockedData".
    • Callback failure - Failure block to be executed if locking fails, returns BayunError.
byte plainData[]; int encryptionPolicy = BayunCore.ENCRYPTION_POLICY_COMPANY;int keyGenerationPolicy = BayunCore.KEY_GENERATION_POLICY_ENVELOPE; String groupId; bayunCore.lockData(plainData, encryptionPolicy, keyGenerationPolicy, groupId, success, failure); // Callbacks for locking data success = new Handler.Callback() { @Override public boolean handleMessage(Message message) { byte[] lockedText = message.getData().getByteArray("lockedData", ""); 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.3.3 Unlock Data

The unlockData method of BayunCore class unlocks generic data of type byteArray.

  • Parameters
    • byte[] data - Byte data to be unlocked.
    • Callback success - Success block to be executed after data is successfully unlocked, returns unlocked data through key "unlockedData".
    • Callback failure - Failure block to be executed if unlocking fails, returns BayunError.
byte lockedData[]; bayunCore.unlockData(lockedData, success, failure); // Callbacks for unlocking data success = new Handler.Callback() { @Override public boolean handleMessage(Message message) { byte[] unlockedText = message.getData().getByteArray("unlockedData", ""); 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 ""