src/extensions/looseassembly/Client/PublicKeyToken.cs
/// <summary>
/// Creates a PublicKeyToken from a long form full public key string (hex characters).
/// </summary>
Creates a PublicKeyToken from a long form full public key string (hex characters).
Creates a PublicKeyToken from a long form full public key string ( hex characters ) .
public static PublicKeyToken FromPublicKeyString(string publicKey)
        {
            if (publicKey is null)
            {
                throw new ArgumentNullException(nameof(publicKey));
            }
            if (publicKey.Length % 2 != 0)
            {
                throw new InvalidOperationException("The key length is not even");
            }
            var keySpan = publicKey.AsSpan();
            var bytes = new byte[publicKey.Length / 2];
            for (var i = 0; i < bytes.Length; i++)
            {
                bytes[i] = byte.Parse(keySpan.Slice(0, 2), System.Globalization.NumberStyles.HexNumber);
                keySpan = keySpan[2..];
            }
            return FromPublicKey(bytes);
        }
public static PublicKeyToken FromPublicKeyString ( string publicKey ) { if ( publicKey is null ) { throw new ArgumentNullException ( nameof ( publicKey ) ) ; } if ( publicKey . Length % 2 != 0 ) { throw new InvalidOperationException ( " " ) ; } var keySpan = publicKey . AsSpan ( ) ; var bytes = new byte [ publicKey . Length / 2 ] ; for ( var i = 0 ; i < bytes . Length ; i ++ ) { bytes [ i ] = byte . Parse ( keySpan . Slice ( 0 , 2 ) , System . Globalization . NumberStyles . HexNumber ) ; keySpan = keySpan [ 2 .. ] ; } return FromPublicKey ( bytes ) ; }
Creates a PublicKeyToken from a long form full public key string (hex characters).
Creates a PublicKeyToken from a long form full public key string ( hex characters ) .
publicKey
string