> For the complete documentation index, see [llms.txt](https://bayun.gitbook.io/bayuncoresdk-cpp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bayun.gitbook.io/bayuncoresdk-cpp/bayuncoresdk-operations/4.4-get-locking-key.md).

# 5.4 Get Locking Key

The `getLockingKey` function of `BayunCore` class returns locking key along with the keys for signature generation and signature verification for an encryption policy.&#x20;

The function takes the following parameters :

* **sessionId** : Unique SessionId which is received in the registration/login function response.
* **encryptionPolicy** : [BayunEncryptionPolicy](/bayuncoresdk-cpp/bayuncoresdk-operations.md#encryption-policy) determines the key to be used to generate the lockingKey.
* **keyGenerationPolicy** : [BayunKeyGenerationPolicy](/bayuncoresdk-cpp/bayuncoresdk-operations.md#key-generation-policy) determine the policy to be used to generate the lockingKey.
* **groupId**: GroupId is required if encryptionPolicy is `BayunEncryptionPolicyGroup`. If encryption-policy is other than `BayunEncryptionPolicyGroup` then groupId should be empty string.

{% tabs %}
{% tab title="C++" %}

```cpp
#include "BayunCore.h"

Bayun::BayunEncryptionPolicy encryptionPolicy = Bayun::BayunEncryptionPolicy::Group;
Bayun::BayunKeyGenerationPolicy keyGenerationPolicy = Bayun::BayunKeyGenerationPolicy::Static;
Bayun::LockingKeys lockingKeys = bayunCore->getLockingKey("<sessionId>", encryptionPolicy,keyGenerationPolicy, "<groupId>");
```

{% endtab %}
{% endtabs %}

The `getLockingKey` function returns a struct `LockingKeys`.

```cpp
struct LockingKeys {
    std::string key; //Locking Key
    std::string signatureKey; //Private Key to be used for signature generation
    std::string signatureVerificationKey; //Public Key to be used for signature verification
};
```
