Method Not Found Using Digestutils in Android

Method not found using DigestUtils in Android

I ran into the same issue trying to use DigestUtils in my Android app. This was the best answer I could find by searching, but I was reluctant to rebuild the .jar file with the namespace changed. After spending some time on this issue, I found an easier way to solve the problem for my case. The problem statement for my code was

String s = DigestUtils.md5Hex(data);

Replace this statement with the following and it will work:

String s = new String(Hex.encodeHex(DigestUtils.md5(data)));

Similarly, for shaHex exampl, you can change it to

String hash = new String(Hex.encodeHex(DigestUtils.sha("textToHash")));

This works because even though Android does not have encodeHexString(), it does have encodeHex(). Hope this would help others who run into the same issue.

java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHexString

Why can't you change the kaltura client?
You have the sources, so just make the necessary change



Related Topics



Leave a reply



Submit