Skip to content

Dart extensions and extension Data. Include base64Encode、base58Encode、hexEncode and Base58Data、Base64Data、HexData.

License

Notifications You must be signed in to change notification settings

kecson/extension_data

Repository files navigation

extension_data

pub package

  • Dart extensions and extension Data.

  • Include base64Encode、base58Encode、hexEncode and Base58Data、Base64Data、HexData.

  • Include DateTime、Iterable、num、String extension.

Usage

import 'package:extension_data/extension_data.dart';

void main() {
  const str = 'extension_data';
  //utf8:  [101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 100, 97, 116, 97]
  final bytes = utf8.encode(str);
  const hexStr = '0x657874656e73696f6e5f64617461';
  const strBs64 = 'ZXh0ZW5zaW9uX2RhdGE=';
  const strBs58 = 'eJdhyKqktt8nj9vnTwe';

  test('Test Codec', () {
    print('$str:  bytes: ${bytes.toList()}');
    //base58
    expect(base58Encode(bytes), strBs58);
    expect(base58Decode(strBs58), bytes);
    //base64
    expect(base64Encode(bytes), strBs64);
    expect(base64Decode(strBs64), bytes);
    //hex
    expect(hexEncode(bytes), hexStr);
    expect(hexDecode(hexStr), bytes);
  });
 test
('Test Data', () {
//base58Data
expect(Base58Data(strBs58).bytes, bytes);
expect(Base58Data.fromBytes(bytes).value, strBs58);
//base64Data
expect(Base64Data(strBs64).bytes, bytes);
expect(Base64Data.fromBytes(bytes).value, strBs64);
//hexData
expect(HexData(hexStr).bytes, bytes);
expect(HexData.fromBytes(bytes).value, hexStr);
});

About

Dart extensions and extension Data. Include base64Encode、base58Encode、hexEncode and Base58Data、Base64Data、HexData.

Topics

Resources

License

Stars

Watchers

Forks

Languages