mirror of
https://github.com/gabehf/tempus.git
synced 2026-03-15 18:25:59 -07:00
Added basic Subsonic interface
This commit is contained in:
parent
3fa634df39
commit
30ded0951b
5 changed files with 221 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
package com.cappielloantonio.play.subsonic.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class StringUtil {
|
||||
public static String tokenize(String s) {
|
||||
final String MD5 = "MD5";
|
||||
try {
|
||||
MessageDigest digest = java.security.MessageDigest.getInstance(MD5);
|
||||
digest.update(s.getBytes());
|
||||
byte messageDigest[] = digest.digest();
|
||||
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aMessageDigest : messageDigest) {
|
||||
String h = Integer.toHexString(0xFF & aMessageDigest);
|
||||
while (h.length() < 2) {
|
||||
h = "0" + h;
|
||||
}
|
||||
hexString.append(h);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue