mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-02 07:23:36 +00:00
Added basic Subsonic interface
This commit is contained in:
@@ -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 "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user