# ENCRYPTED\_STRING macro/function

Use the `ENCRYPTED_STRING` macro/function for each list item in the [`ENCRYPTED_STRING_PROPERTY_LIST_EDIT`](/configuration-subclasses/supported-property-types/encrypted-string.md#nsstring-editable-list-implementation) (Objective-C) macro or [`@EncryptedStringPropertyListEdit`](/configuration-subclasses/supported-property-types/encrypted-string.md#string-editable-list-implementation) (Swift) property wrapper.

### Step 1. Copy the public key

<img src="/files/ZEXn7ysNc9EGtlRVyNvo" alt="" data-size="line"> You can copy the multi line string including the `return` keyword and line breaks as follows (do not include any comments or `#if` macros):

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

<pre class="language-swift"><code class="lang-swift">return "-----BEGIN PUBLIC KEY-----\n" +
    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4TZnKfGeXttN7Rr3eiAZ\n" +
    "PMEPsZvbo7lgIpMh6OjgBsoqkJJP0yXXLtpqsBCv8vm7RYqCn5+yfkiCQiXvkJBz\n" +
<strong>    "FSKmLF9EPR9l1H+32Id82dDuseD70D66puPUHjciEgmU18DpW2NVvTAykMwTEsiR\n" +
</strong>    "0h/ExBEhUe75qtwlVno8cMFbEfVtiGbKECvWIr122ED71T0Jt2Bcxqx1a7c1hPIV\n" +
    "RwLxIfWfE0+2rB9nJVPBgsTVPywibDvjio82FousyMDmvkAbMq5iyuyvJ0+5bATz\n" +
    "o12GEt5lSiQlCMzfmkWYBROMDCh27qGFVVo1XAUCVsMfsW9n4iQcoLAdUp/LI3B3\n" +
    "ywIDAQAB\n" +
    "-----END PUBLIC KEY-----\n"
</code></pre>

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
return @"-----BEGIN PUBLIC KEY-----\n" \
    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4TZnKfGeXttN7Rr3eiAZ\n" \
    "PMEPsZvbo7lgIpMh6OjgBsoqkJJP0yXXLtpqsBCv8vm7RYqCn5+yfkiCQiXvkJBz\n" \
    "FSKmLF9EPR9l1H+32Id82dDuseD70D66puPUHjciEgmU18DpW2NVvTAykMwTEsiR\n" \
    "0h/ExBEhUe75qtwlVno8cMFbEfVtiGbKECvWIr122ED71T0Jt2Bcxqx1a7c1hPIV\n" \
    "RwLxIfWfE0+2rB9nJVPBgsTVPywibDvjio82FousyMDmvkAbMq5iyuyvJ0+5bATz\n" \
    "o12GEt5lSiQlCMzfmkWYBROMDCh27qGFVVo1XAUCVsMfsW9n4iQcoLAdUp/LI3B3\n" \
    "ywIDAQAB\n" \
    "-----END PUBLIC KEY-----\n";
```

{% endtab %}
{% endtabs %}

### Step 2. Paste into the `Public Key` text field

<img src="/files/9YNE8wB3VmskNCO36LR5" alt="" data-size="line"> The public key will be reformatted automatically.

### Step 3. Copy the plaintext value

<img src="/files/d3Gs5W7oNDWnKkAGctHQ" alt="" data-size="line"> Copy the plaintext value from the first parameter of the `ENCRYPTED_STRING` macro/function

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

```swift
@EncryptedStringPropertyListEdit(
    regex: #"https://[\w\.-]\.appfigurate.io/.*"#, 
    description: "server url", 
    encrypted: ENCRYPTED(), 
    restart: false, 
    values: ["Dev":ENCRYPTED_STRING("https://dev.appfigurate.io/list", // param 1 - plaintext
        "")])                                                          // param 2 - ciphertext
var url: String 
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
ENCRYPTED_STRING_PROPERTY_LIST_EDIT(
    url, 
    @"https://[\\w\\.-]+\\.appfigurate.io/.*", 
    @"server url", 
    @{@"Dev":ENCRYPTED_STRING(@"https://dev.appfigurate.io/list", // param 1 - plaintext
      @""                                                         // param 2 - ciphertext
    )}); 
```

{% endtab %}
{% endtabs %}

Copy just the plaintext value without surrounding quotes as follows:

```
https://dev.appfigurate.io/list
```

### Step 4. Paste into the `Plaintext` text field

<img src="/files/xjBYUe42UAcYmR3yJkMs" alt="" data-size="line"> The ciphertext will be computed automatically. e.g.:

```
Bj+pIgNMhv+IRdmUJw6nzhKZmD14uAwe2jz50gYHSvkbgzUkmmpm+fjFsPrprljaPhu3w7xr1KuMkcbjdDpbFBoxSsOcZ3WuxjA5mHv1h/inZpi2/cAH/UjhshPO2VQ8FkWg9shduqCEDbjMuO8ammVA5x+zg7oVTPJXbJUH1P3I49f3Sc/Lg2LpxyEXIDFtgpYq5FX1qNa3mu842OMSkJ6NVEI+CDi4hRNz7P+ie2d8Dqlm+w0cvoV91Dc94bUveQsqiAcshTkqmlxxI5uZc+oKR8pQK+RX0pEZz+U2XR4herhDV3Qd/J8YAhL4qkIpxDMaYmiW7EK0RVszlwSDf/t+jPZE0cYVq3jF/ZYHh1S2k3mFRRnyO/gYgf5+SPB6AQ==
```

{% hint style="success" %}
**Note:** due to the nature of RSA public key encryption, the ciphertext randomly changes for every modification you make.
{% endhint %}

### Step 5. Copy the ciphertext value

<img src="/files/Lu0VZDKFQV1SwNHnMnfE" alt="" data-size="line"> Copy the ciphertext value.

### Step 6. Paste into your subclass

<img src="/files/3YGB65BaQuf5X1AzG1Fv" alt="" data-size="line"> Paste the ciphertext into the second parameter of the `ENCRYPTED_STRING` macro/function

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

```swift
@EncryptedStringPropertyListEdit(
    regex: #"https://[\w\.-]\.appfigurate.io/.*"#, 
    description: "server url", 
    encrypted: ENCRYPTED(), 
    restart: false, 
    values: ["Dev":ENCRYPTED_STRING("https://dev.appfigurate.io/list", // param 1 - plaintext
        "Bj+pIgNMhv+IRdmUJw6nzhKZmD14uAwe2jz50gYHSvkbgzUkmmpm+fjFsPrprljaPhu3w7xr1KuMkcbjdDpbFBoxSsOcZ3WuxjA5mHv1h/inZpi2/cAH/UjhshPO2VQ8FkWg9shduqCEDbjMuO8ammVA5x+zg7oVTPJXbJUH1P3I49f3Sc/Lg2LpxyEXIDFtgpYq5FX1qNa3mu842OMSkJ6NVEI+CDi4hRNz7P+ie2d8Dqlm+w0cvoV91Dc94bUveQsqiAcshTkqmlxxI5uZc+oKR8pQK+RX0pEZz+U2XR4herhDV3Qd/J8YAhL4qkIpxDMaYmiW7EK0RVszlwSDf/t+jPZE0cYVq3jF/ZYHh1S2k3mFRRnyO/gYgf5+SPB6AQ==")]) // param 2 - ciphertext
var url: String
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
ENCRYPTED_STRING_PROPERTY_LIST_EDIT(
    url, 
    @"https://[\\w\\.-]+\\.appfigurate.io/.*", 
    @"server url", 
    @{@"Dev":ENCRYPTED_STRING(@"https://dev.appfigurate.io/list", // param 1 - plaintext
      @"Bj+pIgNMhv+IRdmUJw6nzhKZmD14uAwe2jz50gYHSvkbgzUkmmpm+fjFsPrprljaPhu3w7xr1KuMkcbjdDpbFBoxSsOcZ3WuxjA5mHv1h/inZpi2/cAH/UjhshPO2VQ8FkWg9shduqCEDbjMuO8ammVA5x+zg7oVTPJXbJUH1P3I49f3Sc/Lg2LpxyEXIDFtgpYq5FX1qNa3mu842OMSkJ6NVEI+CDi4hRNz7P+ie2d8Dqlm+w0cvoV91Dc94bUveQsqiAcshTkqmlxxI5uZc+oKR8pQK+RX0pEZz+U2XR4herhDV3Qd/J8YAhL4qkIpxDMaYmiW7EK0RVszlwSDf/t+jPZE0cYVq3jF/ZYHh1S2k3mFRRnyO/gYgf5+SPB6AQ==" // param 2 - ciphertext
    )});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.electricbolt.co.nz/appfigurate-se-user-guide/manual-encryption/encrypted_string-macro-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
