src/Keeg.Crypto/Common/Utils.cs
/// <summary>
/// Converts a byte array to an equivalent hex string.
/// </summary>
/// <param name="data">Byte array to convert.</param>
/// <param name="toLowerCase">If the hex characters should be upper or lowercase.</param>
/// <returns>A <see cref="string"/> of hex characters representing the input byte array.</returns>
Converts a byte array to an equivalent hex string.
Converts a byte array to an equivalent hex string .
internal static string BytesToHex(byte[] data, bool toLowerCase = false)
        {
            byte addByte = (toLowerCase) ? (byte)0x57 : (byte)0x37;
            int length = data.Length;
            char[] c = new char[length * 2];
            byte b;
            for (int i = 0; i < length; ++i)
            {
                b = ((byte)(data[i] >> 4));
                c[i * 2] = (char)(b > 9 ? b + addByte : b + 0x30);
                b = ((byte)(data[i] & 0xF));
                c[i * 2 + 1] = (char)(b > 9 ? b + addByte : b + 0x30);
            }
            return new string(c);
        }
internal static string BytesToHex ( byte [ ] data , bool toLowerCase = false ) { byte addByte = ( toLowerCase ) ? ( byte ) 0x57 : ( byte ) 0x37 ; int length = data . Length ; char [ ] c = new char [ length * 2 ] ; byte b ; for ( int i = 0 ; i < length ; ++ i ) { b = ( ( byte ) ( data [ i ] >> 4 ) ) ; c [ i * 2 ] = ( char ) ( b > 9 ? b + addByte : b + 0x30 ) ; b = ( ( byte ) ( data [ i ] & 0xF ) ) ; c [ i * 2 + 1 ] = ( char ) ( b > 9 ? b + addByte : b + 0x30 ) ; } return new string ( c ) ; }
Converts a byte array to an equivalent hex string.
Converts a byte array to an equivalent hex string .
A  of hex characters representing the input byte array.
A of hex characters representing the input byte array .
data
byte[]
Byte array to convert.
Byte array to convert .
toLowerCase
bool
If the hex characters should be upper or lowercase.
If the hex characters should be upper or lowercase .