I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 50cb4273 authored by zzz's avatar zzz
Browse files

split out md5Sum for use in i2ptunnel

parent 977cdee0
No related branches found
No related tags found
No related merge requests found
...@@ -161,14 +161,28 @@ public class PasswordManager { ...@@ -161,14 +161,28 @@ public class PasswordManager {
*/ */
public static String md5Hex(String subrealm, String user, String pw) { public static String md5Hex(String subrealm, String user, String pw) {
String fullpw = user + ':' + subrealm + ':' + pw; String fullpw = user + ':' + subrealm + ':' + pw;
try {
byte[] data = fullpw.getBytes("ISO-8859-1");
byte[] sum = md5Sum(data);
if (sum != null)
// adds leading zeros if necessary
return DataHelper.toString(sum);
} catch (UnsupportedEncodingException uee) {}
return null;
}
/**
* Standard MD5 checksum
*
* @param data non-null
* @return 16 bytes, or null on error
*/
public static byte[] md5Sum(byte[] data) {
try { try {
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
md.update(fullpw.getBytes("ISO-8859-1")); md.update(data);
// adds leading zeros if necessary return md.digest();
return DataHelper.toString(md.digest()); } catch (NoSuchAlgorithmException nsae) {}
} catch (UnsupportedEncodingException uee) {
} catch (NoSuchAlgorithmException nsae) {
}
return null; return null;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment