bytes.to_base64
bytes.to_base64
Function
Convert Bytes to Base64 text.
Syntax
bytes(value).to_base64(mode)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| mode | String/Int | No | Standard Base64 | Optional standard_no_pad, url_safe, url_safe_no_pad, also compatible with base64 library's 0 to 3 numeric mode. |
Return value
| Type | Description |
|---|---|
| String | Base64 text. |
Code Example
data = bytes('BT') text = data.to_base64() // Output: QlQ= print text
Notes
- To parse Base64 use
bytes(text, 'base64')orbytes({base64: text}).