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


Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

multiple checkboxes with same id