In this blog i will show you how to encode and decode a String using BASE64 encoding/decoding technique.
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class encodeDecode{
public static void main(String args[]){
BASE64Encoder encoder = null;
String encodedText = null;
String decodedText=null;
String text="Java BASE64 Encoding and Decoding example";
byte[] textInBytes=text.getBytes();
encoder = new BASE64Encoder();
encodedText = Base64.encode(textInBytes);
decodedText= new String( Base64.decode(encodedText))
System.out.println("BASE64 Encoded Text : " + encodedText);
System.out.println("Decoded Text : "+decodedText );
}
}
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class encodeDecode{
public static void main(String args[]){
BASE64Encoder encoder = null;
String encodedText = null;
String decodedText=null;
String text="Java BASE64 Encoding and Decoding example";
byte[] textInBytes=text.getBytes();
encoder = new BASE64Encoder();
encodedText = Base64.encode(textInBytes);
decodedText= new String( Base64.decode(encodedText))
System.out.println("BASE64 Encoded Text : " + encodedText);
System.out.println("Decoded Text : "+decodedText );
}
}
No comments:
Post a Comment