### bytes.to_base64

Supported in:

    bytes.to_base64(bytes, optional_default_string)

#### Description

Function converts a `bytes` value to a `base64 encoded string`. Function calls with values that cannot be casted return an empty string by default.

#### Param data types

`BYTES`, `STRING`

#### Return type

`STRING`

#### Code samples

##### Raw Binary Bytes to Base64 Encoded String

The function converts the raw binary bytes to base64 encoded string.

    bytes.to_base64(b'000000006f8ec5586d026f9ddac56e9f2fe15b8a0000000001000000cd000000) = "AAAAAG+OxVhtAm+d2sVuny/hW4oAAAAAAQAAAM0AAAA="

##### Failed Conversion (Defaults to the Optionally Provided String)

The function defaults to the `"invalid bytes"` when the bytes value provided isn't valid.

    bytes.to_base64(b'000000006f8ec5586d", "invalid bytes") = "invalid bytes"