---
title: Base58 Functions
description: Standard library functions for Base58 encoding and decoding
---

## encode_base58

`encode_base58` encodes a buffer or string as a base58 string.

### Inputs

| Name    | Type                  | Description                                                                                                         |
| ------- | --------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `value` | buffer, string, addon | The buffer or string to encode. Strings starting with '0x' are decoded as hex; otherwise, raw UTF-8 bytes are used. |

### Output

| Name    | Type   | Description                           |
| ------- | ------ | ------------------------------------- |
| `value` | string | The input, encoded as a base58 string |

```hcl
output "encoded" {
    value = encode_base58("0xaca1e2ae0c54a9a8f12da5dde27a93bb5ff94aeef722b1e474a16318234f83c8")
}
// > encoded: CctJBuDbaFtojUWfQ3iEcq77eFDjojCtoS4Q59f6bUtF
```

## decode_base58

`decode_base58` decodes a base58 encoded string and returns the result as a
buffer.

### Inputs

| Name            | Type   | Description                 |
| --------------- | ------ | --------------------------- |
| `base58_string` | string | The base58 string to decode |

### Output

| Name    | Type   | Description                            |
| ------- | ------ | -------------------------------------- |
| `value` | buffer | The decoded base58 string, as a buffer |

```hcl
output "decoded" {
    value = decode_base58("CctJBuDbaFtojUWfQ3iEcq77eFDjojCtoS4Q59f6bUtF")
}
// > decoded: 0xaca1e2ae0c54a9a8f12da5dde27a93bb5ff94aeef722b1e474a16318234f83c8
```
