> For the complete documentation index, see [llms.txt](https://docs.bayunsystems.com/bayuncoresdk-python/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bayunsystems.com/bayuncoresdk-python/bayuncoresdk-operations/lock-unlock-text.md).

# 5.2 Lock/Unlock Text

## &#x35;**.2.1 Lock Text**

The `lockText` function of `BayunCore` class locks text with default encryption-policy dictated by server settings.

The function takes the following parameters :

* **sessionId** : Unique SessionId which is received in the authenticate function response.
* **plainText** : Text to be locked.

{% tabs %}
{% tab title="Python" %}

```python
lockedText = bayunCore.lockText("<sessionId>", "<plainText>")
```

{% endtab %}
{% endtabs %}

## **5.2.2 Lock Text with encryption-policy**

The `lockText` function with encryption-policy as an optional parameter locks text with the encryption key dictated by the policy. The function takes the following parameters :

* **sessionId** : Unique SessionId which is received in the authenticate function response.
* **plainText** : Text to be locked.
  * dataType : `string`
* **encryptionPolicy** : [BayunEncryptionPolicy](https://docs.bayunsystems.com/bayuncoresdk-python/bayuncoresdk-operations#encryption-policy) determines the key for locking.
* **keyGenerationPolicy** : [BayunKeyGenerationPolicy](https://docs.bayunsystems.com/bayuncoresdk-python/bayuncoresdk-operations#key-generation-policy) determines the policy to generate the data encryption key.
* **groupId** : GroupId is required if encryptionPolicy is `BayunEncryptionPolicyGroup`.

{% hint style="info" %}
If encryption-policy is other than `BayunEncryptionPolicyGroup` then groupId should be empty string.
{% endhint %}

{% tabs %}
{% tab title="Python" %}

```python
from BayunCore import BayunEncryptionPolicy
from BayunCore import BayunKeyGenerationPolicy

encryptionPolicy = BayunEncryptionPolicy.Company
keyGenerationPolicy = BayunKeyGenerationPolicy.Static
lockedText =  bayunCore.lockText("<sessionId>", "<plainText>", encryptionPolicy, keyGenerationPolicy, "<groupId>")
```

{% endtab %}
{% endtabs %}

## **5.2.3 Unlock Text**

The `unlockText` function of `BayunCore` class unlocks a locked text. The function takes the following parameters :

* **sessionId** : Unique SessionId which is received in the authenticate function response.
* **lockedText** : Text to be unlocked.
  * dataType : `string`

{% tabs %}
{% tab title="Python" %}

```python
plainText = bayunCore.unlockText("<sessionId>", "<lockedText>")
```

{% endtab %}
{% endtabs %}
