Get MD5 String from Message Digest

前端 未结 11 1211
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 20:46

I understand how it works but if I want to print out the MD5 as String how would I do that?

public static void getMD5(String fileName) throws Exception{
            


        
11条回答
  •  借酒劲吻你
    2020-12-23 20:57

    Call hash.digest() to finish the process. It will return an array of bytes.

    You can create a String from a byte[] using a String constructor, however if you want a hex string you'll have to loop through the byte array manually and work out the characters.

提交回复
热议问题