Added basic Subsonic interface

This commit is contained in:
CappielloAntonio
2021-07-24 12:27:45 +02:00
parent 3fa634df39
commit 30ded0951b
5 changed files with 221 additions and 0 deletions

View File

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