> For the complete documentation index, see [llms.txt](https://docs.foreprotocol.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.foreprotocol.io/documentation/developers/ipfs/base58-less-than-greater-than-bytes32.md).

# Base58 <->Bytes32

Storing a string in solidity is quite expensive. So we use the string hash(base58) to bytes32 conversion function. And we store the data as bytes32.

Below are the implementations of the convert function in two directions.

```javascript
import bs58 from 'bs58'

getBytes32FromIpfsHash(ipfsListing) {
  return "0x"+bs58.decode(ipfsListing).slice(2).toString('hex')
}

getIpfsHashFromBytes32(bytes32Hex) {
  const hashHex = "1220" + bytes32Hex.slice(2)
  const hashBytes = Buffer.from(hashHex, 'hex');
  const hashStr = bs58.encode(hashBytes)
  return hashStr
}
```
