Module basic module

module base58

base58 encoding and decoding module

base58Module is a module used for Base58 encoding and decoding of data. Base58 is a combination of numbers and letters. It does not contain easily confused characters such as the number 0, the letter O, the letter I, the letter l, etc., and is less error-prone.

This module provides two methods encode: and . The method is used to Base58 encode the given data and return the encoded string. The method is used to decode the given Base58 encoded string and return the decoded binary data.decodeencodedecode

Here is base58sample code for the module:

1 2 3 4 5 6 7 8
var base58 = require('base58'); var data = "Hello, World!"; var encoded = base58.encode(data); console.log(encoded); // => 'StV1DL6CwTryKyV' var decoded = base58.decode(encoded); console.log(decoded.toString()); // => 'hello world'

static function

encode

Encode data in base58

1
static String base58.encode(Buffer data);

Call parameters:

  • data:Buffer, the data to be encoded

Return results:

  • String, returns the encoded string

Encode data using base58check

1 2
static String base58.encode(Buffer data, Integer chk_ver);

Call parameters:

  • data:Buffer, the data to be encoded
  • chk_ver: Integer, specify the verification version

Return results:

  • String, returns the encoded string

decode

Decode string into binary data using base58 method

1
static Buffer base58.decode(String data);

Call parameters:

  • data: String, the string to be decoded

Return results:

  • Buffer, returns the decoded binary data

Decode string into binary data using base58check method

1 2
static Buffer base58.decode(String data, Integer chk_ver);

Call parameters:

  • data: String, the string to be decoded
  • chk_ver: Integer, specify the verification version

Return results:

  • Buffer, returns the decoded binary data