6.3 Lock/Unlock Binary Data

6.3.1 Lock Data

The lockData method of BayunCore class locks byteArray with default BayunEncryptionPolicy and BayunKeyGenerationPolicy dictated by server settings.

The function takes the following parameters :

  • sessionId : Unique SessionId which is received in the login/registration function response.

  • data : Byte array to be locked.

var data = [104,101,108,108,111]; // sample byte array
var lockedData = await bayunCore.lockData("<sessionId>", data);

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.

  • sessionId : Unique SessionId which is received in the login/registration function response.

  • data : Byte array to be locked.

  • encryptionPolicy : BayunEncryptionPolicy determines the key to be used to generate the lockingKey.

  • keyGenerationPolicy : BayunKeyGenerationPolicy determines the policy to generate the lockingKey.

  • groupId : GroupId is required if encryptionPolicy is GROUP.

If encryptionPolicy is other than GROUP then groupId should be an empty string.

const encryptionPolicy = BayunCore.EncryptionPolicy.GROUP;
const keyGenerationPolicy = BayunCore.KeyGenerationPolicy.ENVELOPE;
const data = [104,101,108,108,111]; // sample byte array

var lockedData = await bayunCore.lockData("<sessionId>", data, 
                                 encryptionPolicy, keyGenerationPolicy, "<groupId>");

6.3.3 Unlock Data

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

  • sessionId : Unique SessionId which is received in the login/registration function response.

  • lockedData : Data to be unlocked.

var unlockedData = await bayunCore.unlockData("<sessionId>", "<lockedData>");

Last updated

Was this helpful?