Created
August 31, 2012 21:31
-
-
Save plytro/3559359 to your computer and use it in GitHub Desktop.
Register subsonic without doing a code patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Running a webserver on port 80, add this to your hosts file | |
// 127.0.0.1 localhost subsonic.org | |
// Then "mkdir ${wwwroot}/backend && echo true >> ${wwwroot}/backend/validateLicense.view" | |
// | |
// Run this in beanshell (bsh) to get the key to match an email address. Enter the address | |
// and output into the correct screen in subsonic and you're done. | |
// | |
// You should be able to remove the hosts file entry at this point.e4658 | |
import java.security.MessageDigest; | |
MessageDigest md5 = MessageDigest.getInstance("MD5"); | |
String emailAddress = "username@example.com"; | |
private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; | |
private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; | |
public static char[] encodeHex(byte[] data) { | |
return encodeHex(data, true); | |
} | |
public static char[] encodeHex(byte[] data, boolean toLowerCase) { | |
return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); | |
} | |
protected static char[] encodeHex(byte[] data, char[] toDigits) { | |
int l = data.length; | |
char[] out = new char[l << 1]; | |
// two characters form the hex value. | |
for (int i = 0, j = 0; i < l; i++) { | |
out[j++] = toDigits[(0xF0 & data[i]) >>> 4]; | |
out[j++] = toDigits[0x0F & data[i]]; | |
} | |
return out; | |
} | |
String foo = new String(encodeHex(md5.digest(emailAddress.getBytes("UTF-8")))); | |
System.out.println(foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment