# llBase64ToInteger

*LSL function*

```lsl
integer integer llBase64ToInteger(string str);
```

- `string str`: Base64-encoded string to decode.

- Returns: `integer`
- Energy: 10

Returns an integer representing the Base64-decoded big-endian value of str. Returns zero if str is longer than 8 characters; the return value is unpredictable if str contains fewer than 6 characters.

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is **str** [Base64](https://wiki.secondlife.com/wiki/Category:LSL_Base64) decoded as a big endian integer.

```lsl title="How to use" frame="terminal"
integer result = llBase64ToInteger("");
```

## Caveats

- If **str** contains fewer than 6 characters, any incomplete least-significant bytes of the integer are set to 0.
- For example, the Base64 value `"qqqqqq=="` corresponds to the hexadecimal value `0xAAAAAAAA`. If the padding "=" characters and the last "q" are dropped, there are 5\*6=30 bits remaining and those can form only 3 full bytes (24 bits). The result is `0xAAAAAA00`.
- The Base64 value `"qqqq"` has 4\*6=24 bits available, which is enough for the same 3 full bytes. The result is also `0xAAAAAA00`.
- Similarly, 3-character Base64 has 18 bits, enough for 2 bytes, and 2-character Base64 has 12 bits, enough for one byte.
- Finally, single-character Base64 has only 6 bits and thus no complete bytes, and the result is always zero.
- Returns zero if **str** is longer than 8 characters.

## Examples

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

```lsl
integer value = llBase64ToInteger("3q0AAA==");

// writes out -559087616
llOwnerSay((string)value);
```

</details>

## See also

### Functions

- [llIntegerToBase64](/functions/llIntegerToBase64/)

### Articles

- [Base64](https://wiki.secondlife.com/wiki/Category:LSL_Base64)

---

*Source: [LlBase64ToInteger](https://wiki.secondlife.com/wiki/LlBase64ToInteger) on the Second Life Wiki. Content from the Second Life Wiki article LlBase64ToInteger (revision 1214991, 2023-10-11), CC BY-SA 3.0.*

---

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