Example usage for java.lang String getBytes

List of usage examples for java.lang String getBytes

Introduction

In this page you can find the example usage for java.lang String getBytes.

Prototype

public byte[] getBytes() 

Source Link

Document

Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.

Usage

From source file:Main.java

/**
 * Metodo che converte la password in Base64
 * @param string = password in chiaro/*from   ww w  .java2s .c om*/
 * @return password cifrata
 */
public static String encodePassword(String string) {
    byte[] data = string.getBytes();
    return Base64.encodeToString(data, Base64.DEFAULT);
}

From source file:Main.java

public static String toHex(String txt) {
    return toHex(txt.getBytes());
}

From source file:Main.java

/**
 * Converts from String to byte array/*from   w w w. ja va  2s .co  m*/
 * @param str - The String to be decoded
 * @return - The returned byte array
 */
public static byte[] decode(String str) {
    return Base64.decode(str.getBytes(), Base64.DEFAULT);
}

From source file:Main.java

public static byte[] base64Encode(String input) {
    return base64Encode(input.getBytes());
}

From source file:Main.java

public static String encode(String str) {
    return Base64.encodeToString(str.getBytes(), Base64.DEFAULT);
}

From source file:Main.java

public static String base64Encode(String msg) {
    return Base64.encodeToString(msg.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
}

From source file:Main.java

public static String encodeToString(String str) {
    return Base64.encodeToString(str.getBytes(), Base64.DEFAULT);
}

From source file:Main.java

public static String base64(String str) {
    return Base64.encodeToString(str.getBytes(), Base64.DEFAULT);
}

From source file:Main.java

public static String stringToBase64(String data) {
    return Base64.encodeToString(data.getBytes(), Base64.DEFAULT);
}

From source file:Main.java

public static ByteArrayInputStream toStream(String str) {
    return new ByteArrayInputStream(str.getBytes());
}