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));
 }
}


================================================================

Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI