> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pbes

> Used to provide encryption of data using a password. The encryption is a PBKDF2 cryptographic key derivation function. The underlying encryption algorithm is rc2.  Note that all Service installations will be using the same salt.

Used to provide encryption of data using a password. The encryption is a PBKDF2 cryptographic key derivation function. The underlying encryption algorithm is rc2.
Note that all Service installations will be using the same salt.

## Constructors

### Pbes()

```crmscript theme={null}
Pbes
```

Initializes a new instance of the Pbes class.

## Methods

## encrypt(Byte\[],String)

The content in the data array will be encrypted using the supplied password. Since this is working on binary data, you must handle character sets if converting between byte data and strings.

```crmscript theme={null}
Byte[] encrypt(Byte[] data,String password)
```

**Returns:** [CRMScript.Global.Byte](CRMScript.Global.Byte)\[] - The returned byte array contains the encrypted data

**Example:**

```crmscript theme={null}
Pbes pbes;
Byte[] content = String("Hello world").toByteArray();
Byte[] encrypted = pbes.encrypt(content, "foobar");
```

## decrypt(Byte\[],String)

The content in the data array will be decrypted using the supplied password. Since this is working on binary data, you must handle character sets if converting between byte data and strings.
Note that this method does not check if the password is the same as used when encrypting. If wrong password is used, you will get something else than the original data back.

```crmscript theme={null}
Byte[] decrypt(Byte[] data,String password)
```

**Returns:** [CRMScript.Global.Byte](CRMScript.Global.Byte)\[] - The returned byte array contains the decrypted data.

**Example:**

```crmscript theme={null}
Pbes pbes;
Byte[] content = String("Hello world").toByteArray();
Byte[] encrypted = pbes.encrypt(content, "foobar");
Byte[] decrypted = pbes.decrypt(encrypted, "foobar");printLine(String(decrypted));
```


## Related topics

- [Namespace CRMScript.Native](/en/automation/crmscript/reference/CRMScript.Native.md)
- [CRMScript Reference](/en/automation/crmscript/reference/index.md)
