Home > Back-end >  How Base58check to Hex Flutter
How Base58check to Hex Flutter

Time:01-23

How to convert Base58check to HexString in Dart language?

Like on this site: https://www.btcschools.net/tron/tron_tool_base58check_hex.php

Take this data as an example:

Base58 String: TNNukJf11S9iJr1RmgViE2kr8LdFCBBeVb - this TRON Wallet

Hex String: 41881d16d9cd320c94d93acbbe52128ccd0ff9a7d4

CodePudding user response:

Here is an example of how to convert Base58check to HexString in Dart:

import 'package:base58check/base58check.dart';

String base58check = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
String hexString = Base58Check.decode(base58check).toHex();
print(hexString);

This example uses the "base58check" package, which can be installed by adding it to your pubspec.yaml file. The Base58Check.decode() method is used to convert the Base58check string to a bytes array, and the toHex() method is used to convert the bytes array to a hex string.

CodePudding user response:

You can use the package base58 to convert Base58check to HexString in Dart. Here's an example of how you can use it:

import 'package:base58/base58.dart';

void main() {
    var base58check = "16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM";
    var hexString = Base58Codec().decode(base58check).toHex();
    print(hexString); 
}

The decode method of the Base58Codec class takes a Base58check encoded string and returns a Uint8List object. The toHex method can then be called on this object to convert it to a HexString.

  • Related