2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-03-27 14:01:35 +00:00
|
|
|
import 'dart:convert';
|
2024-06-14 19:20:28 +00:00
|
|
|
import 'dart:core';
|
2023-03-03 17:35:43 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
import 'package:dart_bs58/dart_bs58.dart';
|
|
|
|
import 'package:dart_bs58check/dart_bs58check.dart';
|
|
|
|
import 'package:hex/hex.dart';
|
2024-05-30 21:09:26 +00:00
|
|
|
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../extensions.dart';
|
2023-03-03 17:35:43 +00:00
|
|
|
|
|
|
|
extension StringExtensions on String {
|
2023-03-27 14:01:35 +00:00
|
|
|
Uint8List get toUint8ListFromUtf8 => Uint8List.fromList(utf8.encode(this));
|
|
|
|
|
2023-03-03 17:35:43 +00:00
|
|
|
Uint8List get toUint8ListFromHex =>
|
|
|
|
Uint8List.fromList(HEX.decode(startsWith("0x") ? substring(2) : this));
|
|
|
|
|
|
|
|
Uint8List get toUint8ListFromBase58Encoded => bs58.decode(this);
|
|
|
|
|
|
|
|
Uint8List get toUint8ListFromBase58CheckEncoded => bs58check.decode(this);
|
|
|
|
|
|
|
|
BigInt get toBigIntFromHex => toUint8ListFromHex.toBigInt;
|
2024-05-30 21:09:26 +00:00
|
|
|
|
|
|
|
String get toHexFromBase64 => base64Decode(LineSplitter.split(this).join())
|
|
|
|
.map((e) => e.toRadixString(16).padLeft(2, '0'))
|
|
|
|
.join();
|
|
|
|
|
|
|
|
String get toHexReversedFromBase64 =>
|
|
|
|
base64Decode(LineSplitter.split(this).join())
|
|
|
|
.reversed
|
|
|
|
.map((e) => e.toRadixString(16).padLeft(2, '0'))
|
|
|
|
.join();
|
2024-06-14 19:20:28 +00:00
|
|
|
|
|
|
|
/// Capitalize the first letter of a string.
|
|
|
|
String capitalize() {
|
|
|
|
return isEmpty ? this : "${this[0].toUpperCase()}${substring(1)}";
|
|
|
|
}
|
2023-03-03 17:35:43 +00:00
|
|
|
}
|