@@ -0,0 +1,1318 @@
+package dea.monitor.tools;%0D%0A%0D%0Aimport java.security.MessageDigest;%0D%0Aimport java.security.NoSuchAlgorithmException;%0D%0Aimport java.util.HashSet;%0D%0Aimport java.util.Set;%0D%0A%0D%0Apublic class EncodeString %7B%0D%0A%09public Set%3CString%3E vaildTypes = new HashSet%3CString%3E();%0D%0A%0D%0A%09public EncodeString() %7B%0D%0A%09%09vaildTypes.add(%22MD5%22);%0D%0A%09%09vaildTypes.add(%22SHA1%22);%0D%0A%09%7D%0D%0A%0D%0A%09public String genResponse(String encodeType, String txt) throws NoSuchAlgorithmException %7B%0D%0A%0D%0A%09%09MessageDigest md = MessageDigest.getInstance(encodeType);%0D%0A%09%09byte%5B%5D arr = txt.getBytes();%0D%0A%09%09arr = md.digest(arr);%0D%0A%09%09StringBuilder sb = new StringBuilder();%0D%0A%09%09for (byte b : arr) %7B%0D%0A%09%09%09sb.append(String.format(%22%2502x%22, b));%0D%0A%09%09%7D%0D%0A%09%09return sb.toString();%0D%0A%09%7D%0D%0A%0D%0A%09public void usage() %7B%0D%0A%09%09System.err.println(%22Usage: EncodeString encodeType textToEncode%22);%0D%0A%09%09System.err.println(%22Where encodeType is one of:%22);%0D%0A%09%09for (String encodeType : vaildTypes) %7B%0D%0A%09%09%09System.err.println(encodeType);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09EncodeString item = new EncodeString();%0D%0A%09%09try %7B%0D%0A%09%09%09if (args.length %3C 2)%0D%0A%09%09%09%09item.usage();%0D%0A%09%09%09else if (!item.vaildTypes.contains(args%5B0%5D))%0D%0A%09%09%09%09item.usage();%0D%0A%09%09%09else %7B%0D%0A%09%09%09%09System.out.println(item.genResponse(args%5B0%5D, args%5B1%5D));%0D%0A%09%09%09%7D%0D%0A%09%09%7D catch (Exception e) %7B%0D%0A%09%09%09System.err.println(e.getMessage());%0D%0A%09%09%09item.usage();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

Add tool to gen MD5 or SHA hash of string