0

im using this code to encrypt my password......

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 "";
}

how can i add a (Secretkey) so i can send the value to a .net

flx
  • 14,146
  • 11
  • 55
  • 70
user2979811
  • 1
  • 1
  • 2
  • 3
    MD5 is not an encrypting algorithm, it's a hashing algorithm and should never be used for hashing passwords, because it's already insecure. – Leandros Feb 26 '14 at 13:00
  • I don't understand your question. What .NET application are you sending this to? What format does it expect? – Duncan Jones Feb 26 '14 at 15:11

1 Answers1

0

What about using AES encryption?

You can find examples yow to use it at What are best practices for using AES encryption in Android?

Community
  • 1
  • 1
Matthew Fisher
  • 173
  • 1
  • 15
  • 1
    as Leandros already said, it's better (because something different) than md5. There is a discussion about how secure it is ( refer to http://stackoverflow.com/a/8669577/1956197) but I think you should use AES – Matthew Fisher Feb 26 '14 at 13:14
  • first thing to know : -MD5 is not an encryption algorithm its a Hashing algorithm , you can't regenerate the data from the hash that u calculated using MD5, on the other side encryption algorithms have provision for encryption and decryption of data – r4jiv007 Feb 26 '14 at 13:15