【问题标题】:encrypting my password using MD5使用 MD5 加密我的密码
【发布时间】:2014-02-26 12:58:27
【问题描述】:

我用这个代码来加密我的密码......

private static final String md5(final String password) {
    try {

        MessageDigest digest = java.security.MessageDigest
                .getInstance("MD5");
        digest.update(password.getBytes());
        byte messageDigest[] = digest.digest();

        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < messageDigest.length; i++) {
            String h = Integer.toHexString(0xFF & messageDigest[i]);
            while (h.length() < 2)
                h = "0" + h;
            hexString.append(h);
        }
        return hexString.toString();

    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return "";
}

我如何添加一个 (Secretkey) 以便将值发送到 .net

【问题讨论】:

  • MD5 不是加密算法,它是一种散列算法,不应该用于散列密码,因为它已经不安全了。
  • 我不明白你的问题。您要将它发送到哪个 .NET 应用程序?它期望什么格式?

标签: android encryption md5


【解决方案1】:

如何使用 AES 加密?

您可以在What are best practices for using AES encryption in Android?找到使用它的示例

【讨论】:

  • 正如 Leandros 已经说过的,它比 md5 更好(因为有些不同)。有一个关于它有多安全的讨论(参考stackoverflow.com/a/8669577/1956197)但我认为你应该使用AES
  • 首先要知道:-MD5 不是一种加密算法,它是一种散列算法,你不能从你使用 MD5 计算的散列中重新生成数据,另一方面加密算法有规定数据的加解密
猜你喜欢
  • 2015-01-13
  • 1970-01-01
  • 2010-12-02
  • 2014-08-01
  • 2016-10-15
  • 2011-05-24
  • 2023-03-30
  • 2012-09-21
  • 2021-04-10
相关资源
最近更新 更多