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

public static String encodeBASE64(String key) throws Exception {
    byte[] data = Base64.encode(key.getBytes(), Base64.DEFAULT);
    String str = String.valueOf(data);
    return str;// new String(Base64.encode(key.getBytes(),
               // Base64.DEFAULT),"UTF-8");
}

From source file:Main.java

/**
 * Encodes input string to Base64//from   w w w .  jav a 2  s. c  o m
 *
 * @param input Input string
 * @return Base64 string
 */
public static String toBase64(String input) {
    String base64Str = Base64.encodeToString(input.getBytes(), Base64.NO_WRAP);
    return base64Str;
}

From source file:Main.java

public static void writeString(String s, ByteArrayOutputStream os) throws IOException {
    os.write(s.getBytes());
    os.write(0); //Null terminator
}

From source file:Main.java

public static InputStream getInputStream(String str) {
    InputStream inputStream = new ByteArrayInputStream(str.getBytes());
    return inputStream;
}

From source file:Main.java

static String createEncodedParam(String rawParam) {
    return Base64.encodeToString(rawParam.getBytes(), Base64.DEFAULT);
}

From source file:br.com.aws.odonto.utils.CryptoApacheCodec.java

/**
 * Codifica string na base 64 (Encoder)/*from   w w w  . j av  a 2 s. c  o  m*/
 */
public static String codificaBase64Encoder(String msg) {
    return new Base64().encodeToString(msg.getBytes());
}

From source file:Main.java

public static byte[] md5(String msg) throws Exception {
    return msg == null ? null : md5(msg.getBytes());
}

From source file:br.gov.to.secad.aede.util.CriptografiaHash.java

static public String decodificar(String valor) {
    byte[] decoded = Base64.decodeBase64(valor.getBytes());
    String decodedString = new String(decoded);
    return decodedString;
}

From source file:Main.java

protected static byte[] decodeBase64(String value) {
    byte[] result = null;
    byte[] binaryData = value.getBytes();
    result = org.apache.commons.codec.binary.Base64.decodeBase64(binaryData);
    //      return value.decodeBase64();
    return result;
}

From source file:Main.java

public static byte[] convertStringToByte(String str) {
    if (str == null)
        return null;
    return str.getBytes();
}