ToByteArray() public static method

Convert a hexadecimal string to a byte array
public static ToByteArray ( String hexString ) : byte[]
hexString String
return byte[]
コード例 #1
0
        /// <summary>
        /// Compute multiplier (k)
        /// </summary>
        private static NetBigInteger ComputeMultiplier()
        {
            string one = NetUtility.ToHexString(N.ToByteArrayUnsigned());
            string two = NetUtility.ToHexString(g.ToByteArrayUnsigned());

            string ccstr = one + two.PadLeft(one.Length, '0');

            byte[] cc = NetUtility.ToByteArray(ccstr);

            var ccHashed = NetUtility.ComputeSHAHash(cc);

            return(new NetBigInteger(NetUtility.ToHexString(ccHashed), 16));
        }
コード例 #2
0
        /// <summary>
        /// Compute intermediate value (u)
        /// </summary>
        public static byte[] ComputeU(byte[] clientPublicEphemeral, byte[] serverPublicEphemeral)
        {
            // u = SHA-1(A || B)
            string one = NetUtility.ToHexString(clientPublicEphemeral);
            string two = NetUtility.ToHexString(serverPublicEphemeral);

            int    len   = 66;        //  Math.Max(one.Length, two.Length);
            string ccstr = one.PadLeft(len, '0') + two.PadLeft(len, '0');

            byte[] cc = NetUtility.ToByteArray(ccstr);

            var ccHashed = NetUtility.ComputeSHAHash(cc);

            return(new NetBigInteger(NetUtility.ToHexString(ccHashed), 16).ToByteArrayUnsigned());
        }