5.3 Lock/Unlock Binary Data

5.3.1 Lock Data

The lockData function of BayunCore class locks binary data with default BayunEncryptionPolicy and BayunKeyGenerationPolicy dictated by server settings.

The function takes the following parameters :

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

  • data : Data to be locked.

    • dataType : unsigned char*

  • data_len : Length of the data to be locked.

    • dataType : size_t

#include "BayunCore.h"

ShLockedData lockedData = bayunCore->lockData("<sessionId>", "<data>", <data_len>);

5.3.2 Lock Data with Encryption Policy, Key Generation Policy

The lockData function with encryption policy, key generation policy as parameters locks data with the encryption key dictated by the policy. The function takes the following parameters :

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

  • data : Data to be locked.

    • dataType : unsigned char*

  • data_len : Length of the data to be locked.

    • dataType : size_t

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

  • keyGenerationPolicy : BayunKeyGenerationPolicy determines the policy to generate the data encryption key.

  • groupId : GroupId is required if encryptionPolicy is BayunEncryptionPolicyGroup.

If encryptionPolicy is other than BayunEncryptionPolicyGroup then groupId should be nil.

#include "BayunCore.h"

Bayun::BayunEncryptionPolicy encryptionPolicy = Bayun::BayunEncryptionPolicy::Company;
Bayun::BayunKeyGenerationPolicy keyGenerationPolicy = Bayun::BayunKeyGenerationPolicy::Envelop;
ShLockedData lockedData = bayunCore->lockData("<sessionId>", "<data>", <data_len>, encryptionPolicy, keyGenerationPolicy, "<groupId>");

5.3.3 Unlock Data

The unlockData function of BayunCore class unlocks a locked binary data. The function takes the following parameters :

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

  • data : Data to be unlocked.

    • dataType : unsigned char*

  • data_len : Length of data to be unlocked.

    • dataType : size_t

#include "BayunCore.h"

ShUnlockedData unlockedData =  bayunCore->unlockData(sessionId, "<data>", <data_len>);

Last updated

Was this helpful?