List of usage examples for java.lang String getBytes
public byte[] getBytes()
From source file:Main.java
public static String getFromBase64(String str) { String enToStr = Base64.encodeToString(str.getBytes(), Base64.DEFAULT); return enToStr; }
From source file:Main.java
public static String deToStr(String str) { String deStr = new String(Base64.decode(str.getBytes(), Base64.DEFAULT)); return deStr; }
From source file:Main.java
public static String encodeByBase64(String string) { byte[] encode = Base64.encode(string.getBytes(), Base64.DEFAULT); String result = new String(encode); return result; }
From source file:MD5StringUtil.java
public static String md5StringFor(String s) { final byte[] hash = digest.digest(s.getBytes()); final StringBuilder builder = new StringBuilder(); for (byte b : hash) { builder.append(Integer.toString(b & 0xFF, 16)); }//from ww w . j a v a2 s . c om return builder.toString(); }
From source file:Main.java
public static String base64Encode(String str) { return Base64.encodeToString(str.getBytes(), Base64.DEFAULT); }
From source file:Main.java
public static Bitmap decodeImageBase64(String bitmapString) { byte[] bytes = Base64.decode(bitmapString.getBytes(), Base64.DEFAULT); return BitmapFactory.decodeByteArray(bytes, 0, bytes.length); }
From source file:Main.java
/** * @comment_sp Saca XMLNamespace/*from www .j a v a2 s . c o m*/ * @comment_ko removeXMLNamespace * @param source * @return */ public static byte[] removeXMLNamespace(byte source[]) { byte oldContent[] = new byte[source.length]; System.arraycopy(source, 0, oldContent, 0, source.length); String s = new String(oldContent); int startIndex = s.indexOf("xmlns"); int endIndex = s.indexOf(">", startIndex); StringBuffer sb = new StringBuffer(s); sb = sb.delete(startIndex - 1, endIndex); String input = new String(sb); return input.getBytes(); }
From source file:Main.java
public static byte[] toFormattedByteArray(String baseString) { return toFormattedByteArray(baseString.getBytes()); }
From source file:Main.java
public static byte[] md5(String s) throws NoSuchAlgorithmException { return md5(s.getBytes()); }
From source file:Main.java
/** * /*ww w . j a va2 s. co m*/ * @param word * the string to be hashed * @return SHA1-hash of the word */ public static String hash(String word) { byte[] data = word.getBytes(); MessageDigest md = null; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } byte[] b = md.digest(data); String result = ""; for (int i = 0; i < b.length; i++) { result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1); } return result; }