示例#1
0
        public static BigInteger CreateFromUnsignedBigEndianHexString(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentException(nameof(value) + " is null or whitespace");
            }

            byte[] bytes = HexUtilities.HexStringToBytes(value);
            return(CreateFromUnsignedBigEndianBytes(bytes));
        }
        public static string PositiveValToHexString(this BigInteger x, bool lowerCase = true)
        {
            var    bytes     = x.PositiveValToBigEndianBytes();
            string hexString = HexUtilities.BytesToHexString(bytes, lowerCase);

            if (hexString.StartsWith("0"))
            {
                return(hexString.Substring(1));
            }
            else
            {
                return(hexString);
            }
        }
        public static string PositiveValToHexString(this BigInteger x, int minWidth, bool lowerCase = true)
        {
            var minBytes = minWidth / 2 + minWidth % 2;
            var bytes    = x.PositiveValToBigEndianBytes();

            if (bytes.Length >= minBytes)
            {
                return(HexUtilities.BytesToHexString(bytes, lowerCase));
            }
            else
            {
                byte[] expanded = new byte[minBytes];
                Buffer.BlockCopy(bytes, 0, expanded, expanded.Length - bytes.Length, bytes.Length);
                string hexString = HexUtilities.BytesToHexString(expanded, lowerCase);
                if (hexString.Length > minWidth)
                {
                    return(hexString.Substring(1));
                }
                else
                {
                    return(hexString);
                }
            }
        }
示例#4
0
        public static PublicKey Parse(string hexString, bool testNet = false)
        {
            var bytes = HexUtilities.HexStringToBytes(hexString);

            return(Parse(bytes, testNet));
        }
示例#5
0
 public string GetPublicKeyHexString(bool lowerCase = true)
 {
     return(HexUtilities.BytesToHexString(GetPublicKeyBytes(), lowerCase));
 }