Skip to content

minikin/base58

Base58 encoding and decoding for Dart

CI Status Result Type is released under the MIT license. PRs welcome!

Content

Features

The Base58 is a group of binary-to-text encoding schemes used to represent large integers as alphanumeric text. It's designed for use in Bitcoin and is used in many other cryptocurrencies.

  • Encodes and decodes Base58.

Requirements

  • Dart: 2.18.6+

Install

dependencies:
  base58: ^0.0.1

Example

The detailed example can be found at base58/example/example.dart.

import 'dart:convert';

import 'package:base58/base58.dart';

void main() {
  /// Initialize btcBase58 class.
  final btcBase58 = Base58.btc();

  /// Encode raw bytes to String.
  final encodedString = btcBase58.encode([
    84,
    104,
    105,
    115,
    32,
    105,
    115,
    32,
    98,
    97,
    115,
    101,
    53,
    56,
    32,
    101,
    120,
    97,
    109,
    112,
    108,
    101,
    46,
  ]);
  print(encodedString);

  /// Prints:
  /// `2k7m8YHnAT7drBUN3ri5ajasSA5sqWAq`

  /// Decode String to Raw bytes.
  final decodedRawBytes = btcBase58.decode(encodedString);
  print(decodedRawBytes);

  /// Prints:
  /// `[84, 104, 105, 115, 32, 105, 115, 32, 98, 97, 115, 101, 53, 56, 32, 101, 120, 97, 109, 112, 108, 101, 46]`

  print(utf8.decode(decodedRawBytes));

  /// Prints:
  /// `This is base58 example.`
}

To see examples of the following package in action:

cd example && dart run

Support

Post issues and feature requests on the GitHub issue tracker.

License

The source code is distributed under the MIT license. See the LICENSE file for more info.

About

Base58 encoding and decoding for Dart and Flutter.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Languages