6.3 Lock/Unlock Data
6.3.1 Lock Data
The lockData method of BayunCore class locks generic data of type byteArray with default BayunEncryptionPolicy and BayunKeyGenerationPolicy dictated by server settings.
Parameters
data : Byte Array to be locked.
success : Success block to be executed after data is successfully locked, returns locked data through key "lockedData".
failure : Failure block to be executed if locking fails, returns BayunError.
byte plainData[] = "Hello World".getBytes();
//Success Callback
Handler.Callback success = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
byte[] lockedData = message.getData().getByteArray("lockedData");
Log.d(TAG, "Data locked successfully.");
return false;
}
}
//Failure Callback
Handler.Callback failure = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String error = message.getData().getString("BayunError", "");
Log.d(TAG, "Error locking data.");
return false;
}
};
bayunCore.lockData(plainData, success, failure);6.3.2 Lock Data with Encryption Policy, Key Generation Policy
The lockData method with encryption policy, key generation policy as parameters locks data with the encryption key dictated by the policy.
Parameters
data : Byte Array to be locked.
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 through key "lockedData".
failure : Failure block to be executed if locking fails, returns BayunError.
6.3.3 Unlock Data
The unlockData method of BayunCore class unlocks generic data of type byteArray.
Parameters
data : Byte Array to be unlocked.
success : Success block to be executed after data is successfully unlocked, returns unlocked data through key "unlockedData".
failure : Failure block to be executed if unlocking fails, returns
BayunError.
Last updated
Was this helpful?