# llStringToBase64

*LSL function*

```lsl
string string llStringToBase64(string str);
```

- `string str`: Source string to encode.

- Returns: `string`
- Energy: 10

If extra bits are needed to complete the last base64 symbol, those extra bits will be zero.

To go in the other direction, use [llBase64ToString](/functions/llBase64ToString/). Returns the Base64 representation string of str, interpreting it as a UTF-8 byte sequence.

```lsl title="How to use" frame="terminal"
string result = llStringToBase64("");
```

## Examples

<details open>
<summary>Example 1</summary>

```lsl
integer getStringBytes(string msg) {
    return (llStringLength((string)llParseString2List(llStringToBase64(msg), ["="], [])) * 3) >> 2;
}
```

</details>

## See also

### Functions

- [llBase64ToString](/functions/llBase64ToString/)
- [llBase64ToInteger](/functions/llBase64ToInteger/)
- [llIntegerToBase64](/functions/llIntegerToBase64/)
- [llXorBase64](/functions/llXorBase64/)

---

*Source: [LlStringToBase64](https://wiki.secondlife.com/wiki/LlStringToBase64) on the Second Life Wiki. Content from the Second Life Wiki article LlStringToBase64 (revision 1194365, 2015-01-22), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llStringToBase64/
