This example showcases some of the basic data encoding utils in quais. It is comprised of 3 example scripts:
To install dependencies, navigate to this directory (quais-by-example/util-encoding
) and run:
npm install
Use nodejs to run any of the scripts in this example. For example:
node base58.js
This script takes an initial string, decodes it to a Uint8Array, and then encodes it back to a string using base58. To run the script, you'll need to edit the toDecode
variable:
const toDecode = 'hello world'
Once you've done that, you can run the script with:
node base58.js
The script will output the decoded and encoded strings.
This script takes an initial string, decodes it to a Uint8Array, and then encodes it back to a string using base64. To run the script, you'll need to edit the toDecode
variable:
const toDecode = 'base64 encoding is fun!'
Once you've done that, you can run the script with:
node base64.js
The script will output the decoded and encoded strings.
This script takes an initial hex-string, encodes it using RLP encoding, and then decodes it back to a hex-string. To run the script, you'll need to edit the toEncode
variable:
const toEncode = '0x1234'
Once you've done that, you can run the script with:
node rlp.js
The script will output the encoded and decoded hex-strings.