List of usage examples for java.lang String getBytes
public byte[] getBytes()
From source file:com.duy.pascal.ui.purchase.StringXor.java
@NonNull public static String encode(String s) { return new String(Base64.encodeBase64((s.getBytes()))); }
From source file:com.duy.pascal.ui.purchase.StringXor.java
@NonNull public static String decode(String s) { return new String((Base64.decodeBase64(s.getBytes()))); }
From source file:Main.java
public static byte[] hexStringToBytes(String hexString) { byte[] hsb = hexString.getBytes(); byte[] bytes = null; int j, n = 0; for (j = 0; j < 2; j++) { int i = 0; byte b = 0; if (j == 1) bytes = new byte[n]; n = 0;//from www .j av a 2 s. co m for (byte c : hsb) { boolean isHexDigit = (c >= 48 && c <= 57) || (c >= 65 && c <= 70) || (c >= 97 && c <= 102); if (isHexDigit) { c = (byte) ((c & 0xDF) - 48); if (c > 9) c -= 7; b = (byte) ((b << 4) + (0x0f & c)); i++; } if ((i > 0 && !isHexDigit) || i > 1) { if (j == 1) bytes[n] = b; b = 0; n++; i = 0; } } } return bytes; }
From source file:Main.java
public static String createAuthorizationString(String username, String password) { String usernamePassword = username + ":" + password; return "Basic " + Base64.encodeToString(usernamePassword.getBytes(), Base64.NO_WRAP); }
From source file:Main.java
public static final String getHttpBasicAuthHeader(String username, String password) { String digest = username + ":" + password; return "Basic " + Base64.encodeToString(digest.getBytes(), Base64.NO_WRAP); }
From source file:Main.java
public static String encryptHmacMD5ToString(String data, String key) { return encryptHmacMD5ToString(data.getBytes(), key.getBytes()); }
From source file:Main.java
private static byte[] getKey(String password) { byte[] rByte = null; if (password != null) { rByte = password.getBytes(); } else {//from www . j a v a 2s. c o m rByte = new byte[24]; } return rByte; }
From source file:info.magnolia.cms.security.auth.Base64CallbackHandler.java
/** * @param credentials to be decoded/*ww w .j a v a 2s . c o m*/ * @return String decoded credentials <b>name:password </b> */ private static String getDecodedCredentials(String credentials) { return (new String(Base64.decodeBase64(credentials.getBytes()))); }
From source file:Main.java
public static String makeBase64(String message) { if (message != null) { return Base64.encodeToString(message.getBytes(), Base64.URL_SAFE); } else// w ww .ja va 2 s. co m return null; }
From source file:Main.java
public static String encryptHmacSHA1ToString(String data, String key) { return encryptHmacSHA1ToString(data.getBytes(), key.getBytes()); }