Esempio n. 1
0
        private static string ToChecksumAddress(string hex)
        {
            byte[] bytes   = Encoding.ASCII.GetBytes(hex);
            byte[] hash    = CalculateHash(bytes);
            string hashHex = ByteUtil.Hex(hash);
            string address = string.Empty;

            for (var i = 0; i < hex.Length; i++)
            {
                char c = hex[i];
                address += (hashHex[i] >= '8') ? char.ToUpper(c, CultureInfo.InvariantCulture) : c;
            }

            return(address);
        }
Esempio n. 2
0
        public string ToHex()
        {
            string hex = ByteUtil.Hex(ToByteArray());

            byte[] bytes   = Encoding.ASCII.GetBytes(hex);
            byte[] hash    = CalculateHash(bytes);
            string hashHex = ByteUtil.Hex(hash);
            string address = string.Empty;

            for (var i = 0; i < hex.Length; i++)
            {
                char c = hex[i];
                address += (hashHex[i] >= '8') ? char.ToUpper(c) : c;
            }

            return(address);
        }
Esempio n. 3
0
 public override string ToString()
 {
     return(ByteUtil.Hex(ToByteArray()));
 }
Esempio n. 4
0
        public string ToHex()
        {
            string hex = ByteUtil.Hex(ToByteArray());

            return(ToChecksumAddress(hex));
        }
Esempio n. 5
0
 public string ToHex()
 {
     return(ByteUtil.Hex(ToByteArray()));
 }