Exemple #1
0
        public static string SHA256(string data)
        {
            var bytes  = Hex.Hex2Bytes(data);
            var hashed = SHA256(bytes);

            return(Hex.Bytes2Hex(hashed));
        }
Exemple #2
0
        public static string RIPEMD160(string data)
        {
            var bytes  = Hex.Hex2Bytes(data);
            var hashed = RIPEMD160(bytes);

            return(Hex.Bytes2Hex(hashed));
        }
Exemple #3
0
        public static string GenerateSecp256k1PublicKey(string privateKey, bool useCompression)
        {
            var        Ecc          = SecNamedCurves.GetByName("secp256k1");
            var        DomainParams = new ECDomainParameters(Ecc.Curve, Ecc.G, Ecc.N, Ecc.H);
            var        bytes        = Hex.Hex2Bytes(privateKey);
            BigInteger d            = new BigInteger(bytes);
            ECPoint    q            = DomainParams.G.Multiply(d);

            q = q.Normalize();
            var     publicParams = new ECPublicKeyParameters(q, DomainParams);
            FpPoint fp           = new FpPoint(Ecc.Curve, q.AffineXCoord, q.AffineYCoord);

            return(Hex.Bytes2Hex(fp.GetEncoded(useCompression)));
        }
 /// <summary>
 /// Output as hexadecimal binary encoding
 /// </summary>
 /// <returns></returns>
 public new string ToString()
 {
     return(Hex.Bytes2Hex(_bytes));
 }