Get MD5 String from Message Digest

前端 未结 11 1185
伪装坚强ぢ
伪装坚强ぢ 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 21:10

    With the byte array, result from message digest:

    ...
    byte hashgerado[] = md.digest(entrada);
    ...
    
    for(byte b : hashgerado)
        System.out.printf("%02x", Byte.toUnsignedInt(b));
    

    Result (for example):
    89e8a9f68ad3c4bba9b9d3581cf5201d

提交回复
热议问题