本文介绍了给错误:消息摘要无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用户反馈密码转换为MD5哈希值。下面code smippet从一个博客服用。但它显示出在Eclipse错误(Android开发):

I am trying to convert a user fed password into a md5 hash. The following code smippet was taken from a weblog. But it is showing error in eclipse (android development):

消息摘要不能得到解决。

MessageDigest cannot be resolved.

public class MainActivity extends Activity {

private String md5(String in) {
    MessageDigest digest;
    try {
        digest = MessageDisgest.getInstance("MD5");
        digest.reset();
        digest.update(in.getBytes());
        byte[] a = digest.digest();
        int len = a.length;
        StringBuilder sb = new StringBuilder(len << 1);
        for(int i=0;i<len;i++) {
            sb.append(Character.forDigit((a[i] & 0xf0) >> 4, 16));
            sb.append(Character.forDigit(a[i] & 0x0f, 16));
        }
        return sb.toString();
    } catch (NoSuchAlgorithmException e) { e.printStackTrace();}
    return null;

}

我无法找到任何错误。可能是什么问题?

I am not able to find any error. What could be wrong?

推荐答案

尝试改变 MessageDisgest 消息摘要

这篇关于给错误:消息摘要无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 14:32