Base 64 encryption decryption in java using apache codec
First download jar from apache.. commons-codec-1.7.jar and add this to your lib...
-----------------------------------------------------------------------------------------
import org.apache.commons.codec.binary.Base64;
public class Base64TestUsingApacheCodec {
public static void main(String[] args) {
String testStr="Hello ! test this";
byte[] encodedBytes = Base64.encodeBase64(testStr.getBytes());
System.out.println("encodedBytes " + new String(encodedBytes));
byte[] decodedBytes = Base64.decodeBase64(encodedBytes);
System.out.println("decodedBytes " + new String(decodedBytes));
}
}
================================================================
-----------------------------------------------------------------------------------------
import org.apache.commons.codec.binary.Base64;
public class Base64TestUsingApacheCodec {
public static void main(String[] args) {
String testStr="Hello ! test this";
byte[] encodedBytes = Base64.encodeBase64(testStr.getBytes());
System.out.println("encodedBytes " + new String(encodedBytes));
byte[] decodedBytes = Base64.decodeBase64(encodedBytes);
System.out.println("decodedBytes " + new String(decodedBytes));
}
}
================================================================
Comments
Post a Comment