As first, you will need to install some dependencies:
sudo apt update && sudo apt install libclang-dev clang git curlsudo yum makecache && sudo yum install clang clang-devel git curlThen, ensure that Rust is installed on your system. Use the following command to install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shYou will need certain packages to build PostgreSQL and its extensions:
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-configsudo yum install -y bison-devel readline-devel zlib-devel openssl-devel wget ccache && sudo yum groupinstall -y 'Development Tools'git clone https://github.com/Fell-x27/pg_base58.git
cd pg_base58
cargo install cargo-pgrx
cargo pgrx initInside the project directory build the extension using the following command:
cargo pgrx packageTo install the extension, run:
cargo pgrx install --no-default-features --release --sudoOnce the extension is installed, you need to create it in your PostgreSQL database:
CREATE EXTENSION IF NOT EXISTS pg_base58;After the extension is successfully created, you can start using the base58_encode and base58_decode functions.
Encode a string to Base58:
SELECT base58_encode('hello'::bytea);Decode a Base58 string back to its original form:
SELECT base58_decode('Cn8eVZg');