Converting a md5 hash byte array to a string

前端 未结 7 1655
余生分开走
余生分开走 2021-01-31 13:28

How can I convert the hashed result, which is a byte array, to a string?

byte[] bytePassword = Encoding.UTF8.GetBytes(password);

using (MD5 md5 = MD5.Create())
         


        
7条回答
  •  名媛妹妹
    2021-01-31 14:05

    If you're in the 'Hex preference' camp you can do this. This is basically a minimal version of the answer by Philippe Leybaert.

    string.Concat(hash.Select(x => x.ToString("X2")))
    

    B1DB2CC0BAEE67EA47CFAEDBF2D747DF

提交回复
热议问题