ould not find method org.apache.commons.codec.binary.Hex.encodeHexString, referenced from method org.apache.commons.codec.digest.DigestUtils.shaHex




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.



更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 使用delphi 开发多层应用(十三)使用Basic4a
  2. (转载)Android下Affinities和Task
  3. Android中称为四大组件
  4. activity 生命周期
  5. 开源阅读器FBReader Android版本的编译
  6. android瀑布流
  7. android bionic缺失pthread_cancel的解决
  8. Android四大组件之Activity---生命周期那
  9. Android(安卓)3D旋转动画之Camera 和 Mat
  10. Android中的动画有哪几类?各自的特点和区