6.2.1 Lock Text
The lockText
method of BayunCore
class locks text with default encryption-policy
and key-generation-policy
dictated by server settings.
Parameters
text : Text to be locked.
success : Success block to be executed after text is successfully locked, returns locked text through key "lockedText".
failure : Failure block to be executed if locking fails, returns BayunError
.
String plaintext = "<plaintext>";
// Callbacks for locking text
Handler.Callback success = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String lockedText = message.getData().getString("lockedText", "");
return false;
}
}
Handler.Callback failure = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String error = message.getData().getString("BayunError", "");
Log.d(TAG, "Error locking text.");
return false;
}
};
bayunCore.lockText(plaintext, success, failure);
val plaintext = "<plainText>"
// Callbacks for locking text
val success = Handler.Callback {
val lockedText = it.data.getString("lockedText", "")
false
}
val failure = Handler.Callback {
val error = it.data.getString("BayunError", "")
Log.d(TAG, "Error locking text.")
false
}
bayunCore.lockText(plaintext, success, failure)
6.2.2 Lock Text with Encryption Policy, Key Generation Policy
The lockText
method with encryption policy, key generation policy as parameters locks text with the encryption key dictated by the policy.
Parameters
text : Text to be locked.
groupId : GroupId is required if encryptionPolicy is BayunEncryptionPolicyGroup
.
success : Success block to be executed after text is successfully locked, returns locked text through key "lockedText".
failure : Failure block to be executed if locking fails, returns BayunError
.
String plaintext = "<plainText>";
int encryptionPolicy = BayunCore.ENCRYPTION_POLICY_COMPANY;
int keyGenerationPolicy = BayunCore.KEY_GENERATION_POLICY_ENVELOPE;
String groupId = "<groupId>";
// Callbacks for locking text
Handler.Callback success = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String lockedText = message.getData().getString("lockedText", "");
return false;
}
}
Handler.Callback failure = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String error = message.getData().getString("BayunError", "");
Log.d(TAG, "Error locking text.");
return false;
}
};
bayunCore.lockText(plaintext, encryptionPolicy, keyGenerationPolicy, groupId, success, failure);
val plaintext = "<plainText>"
val encryptionPolicy = BayunCore.ENCRYPTION_POLICY_COMPANY
val keyGenerationPolicy = BayunCore.KEY_GENERATION_POLICY_ENVELOPE
val groupId = "<groupId>"
// Callbacks for locking text
val success = Handler.Callback {
val lockedText = it.data.getString("lockedText", "")
false
}
val failure = Handler.Callback {
val error = it.data.getString("BayunError", "")
Log.d(TAG, "Error locking text.")
false
}
bayunCore.lockText(plaintext, encryptionPolicy, keyGenerationPolicy, groupId, success, failure)
6.2.3 Unlock Text
The unlockText
method of BayunCore
class unlocks text.
Parameters
text : Text to be unlocked.
success : Success block to be executed after text is successfully unlocked, returns unlocked text through key "unlockedText".
failure : Failure block to be executed if unlocking fails, returns BayunError.
String lockedText = "<lockedText>";
// Callbacks for unlocking text
Handler.Callback success = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String unlockedText = message.getData().getString("unlockedText", "");
return false;
}
}
Handler.Callback failure = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String error = message.getData().getString("BayunError", "");
Log.d(TAG, "Error unlocking text.");
return false;
}
};
bayunCore.unlockText(lockedText, success, failure);
val lockedText = "<lockedText>"
// Callbacks for unlocking text
val success = Handler.Callback {
val unlockedText = it.data.getString("unlockedText", "")
false
}
val failure = Handler.Callback {
val error = it.data.getString("BayunError", "")
Log.d(TAG, "Error unlocking text.")
false
}
bayunCore.unlockText(lockedText, success, failure)
Last updated