将MD5数组转换为String java [英] Convert MD5 array to String java
本文介绍了将MD5数组转换为String java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道有很多类似的主题,但仍然......有人能为我提供生成MD5字符串的方法的工作示例。
我正在使用MessageDigest,而我m执行以下操作以获取字符串
I know that there is a lot of similar topics, but still... can someone provide me a working example of method which generates MD5 String.
I'm currently using MessageDigest, and I'm doing the following to get a string
sun.misc.BASE64Encoder().encode(messageDigest.digest())
我想有更好的方法可以做到这一点。
提前致谢!
I guess there is some better way to do that.
Thanks in advance!
推荐答案
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] arr = md.digest(bytesOfMessage);
return Base64.getEncoder().encodeToString(arr);
注意:md5不再被认为是好的哈希算法,考虑选择SHA
note: md5 is not considered as good hash algorithm anymore, consider choosing SHAs
这篇关于将MD5数组转换为String java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文