package practice;
import java.io.UnsupportedEncodingException;
import javax.xml.bind.DatatypeConverter;
public class test {
public static void main(String[] args) throws UnsupportedEncodingException {
String str = "77+9x6s=";
// encode data using BASE64
//printBase64Binary(byte[] val)
//This method converts an array of bytes into a string
String encoded = DatatypeConverter.printBase64Binary(str.getBytes());//static String .
System.out.println("encoded value is \t" + encoded);
// Decode data
String decoded = new String(DatatypeConverter.parseBase64Binary(encoded));
System.out.println("decoded value is \t" + decoded);
System.out.println("original value is \t" + str);
}
}
import java.io.UnsupportedEncodingException;
import javax.xml.bind.DatatypeConverter;
public class test {
public static void main(String[] args) throws UnsupportedEncodingException {
String str = "77+9x6s=";
// encode data using BASE64
//printBase64Binary(byte[] val)
//This method converts an array of bytes into a string
String encoded = DatatypeConverter.printBase64Binary(str.getBytes());//static String .
System.out.println("encoded value is \t" + encoded);
// Decode data
String decoded = new String(DatatypeConverter.parseBase64Binary(encoded));
System.out.println("decoded value is \t" + decoded);
System.out.println("original value is \t" + str);
}
}
No comments:
Post a Comment