return chopAtWord(string, length, -1);
/** * Creates an MD5 Checksum of a File, given the Filepath * @param filepath * @return md5 checksum * @throws IOException * @throws NoSuchAlgorithmException * @throws Exception */ public static String getMD5Checksum(String filepath) throws NoSuchAlgorithmException, IOException { byte[] b = createChecksum(filepath); String result = ""; for (int i = 0; i < b.length; i++) { result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1); } return result; }
/** * Decodes a base64 String. * * @param data * a base64 encoded String to decode. * @return the decoded String. */ public static String decodeBase64(String data) { byte[] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { // Nothing to do } return decodeBase64(bytes); }
public synchronized static String hash(byte[] data) { if (digest == null) { try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException nsae) { // Nothing to do } } // Now, compute hash. digest.update(data); return encodeHex(digest.digest()); }
/** * Encodes a String as a base64 String. * * @param data * a String to encode. * @return a base64 encoded String. */ public static String encodeBase64(String data) { byte[] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { // Nothing to do } return encodeBase64(bytes); }
case KeyEvent.KEY_PRESSED: s.append("pressed "); s.append(getKeyText(key.getKeyCode())).append(" "); break; case KeyEvent.KEY_RELEASED: s.append("released "); s.append(getKeyText(key.getKeyCode())).append(" "); break; default:
builder.append(three+"<to>").append(m.getTo()).append("</to>\n"); builder.append(three+"<from>").append(m.getFrom()).append("</from>\n"); builder.append(three+"<body>").append(StringUtils.escapeForXML(m.getBody())).append("</body>\n");
if ( installerFiles.contains( f ) ) final String oldfile = StringUtils.getMD5Checksum( jarFile.getAbsolutePath() ); final String newfile = StringUtils.getMD5Checksum( f.getAbsolutePath() );
s = s.replace("<br>", "\n"); int linebreaks = org.jivesoftware.spark.util.StringUtils. countNumberOfOccurences(s,'\n');
.getUserNicknameFromJID(message.getFrom().asBareJid()); String body = org.jivesoftware.spark.util.StringUtils .escapeHTMLTags(message.getBody()); if (nickname.equals(message.getFrom())) { BareJid otherJID = message
return encodeHex(digest.digest());