Remove the unused md5Hex method

master
jvoisin 5 years ago
parent d07d0ad687
commit d2ad85447b
  1. 20
      airsonic-main/src/main/java/org/airsonic/player/util/StringUtil.java
  2. 6
      airsonic-main/src/test/java/org/airsonic/player/util/StringUtilTestCase.java

@ -29,7 +29,6 @@ import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.text.*;
import java.util.*;
import java.util.regex.Matcher;
@ -331,25 +330,6 @@ public final class StringUtil {
return new String(Hex.decodeHex(s.toCharArray()), StandardCharsets.UTF_8);
}
/**
* Calculates the MD5 digest and returns the value as a 32 character hex string.
*
* @param s Data to digest.
* @return MD5 digest as a hex string.
*/
public static String md5Hex(String s) {
if (s == null) {
return null;
}
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
return new String(Hex.encodeHex(md5.digest(s.getBytes(StandardCharsets.UTF_8))));
} catch (Exception x) {
throw new RuntimeException(x.getMessage(), x);
}
}
/**
* Returns the file part of an URL. For instance:
* <p/>

@ -147,12 +147,6 @@ public class StringUtilTestCase extends TestCase {
assertEquals("Error in utf8hex.", s, StringUtil.utf8HexDecode(StringUtil.utf8HexEncode(s)));
}
public void testMd5Hex() {
assertNull("Error in md5Hex().", StringUtil.md5Hex(null));
assertEquals("Error in md5Hex().", "d41d8cd98f00b204e9800998ecf8427e", StringUtil.md5Hex(""));
assertEquals("Error in md5Hex().", "308ed0af23d48f6d2fd4717e77a23e0c", StringUtil.md5Hex("sindre@activeobjects.no"));
}
public void testGetUrlFile() {
assertEquals("Error in getUrlFile().", "foo.mp3", StringUtil.getUrlFile("http://www.asdf.com/foo.mp3"));
assertEquals("Error in getUrlFile().", "foo.mp3", StringUtil.getUrlFile("http://www.asdf.com/bar/foo.mp3"));

Loading…
Cancel
Save