tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Commons > How to encode and decode in Base64

How to encode and decode in Base64 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use Base64.encode() and Base64.decode() APIs.

File Name  :  
com/bethecoder/tutorials/jodd/encode/Base64Test.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jodd.encode;

import jodd.util.Base64;

public class Base64Test {

  /**
   @param args
   */
  public static void main(String[] args) {

    String str = "BE THE CODER";
    
    String encoded = Base64.encodeToString(str);
    System.out.println(encoded);
    
    String decoded = Base64.decodeToString(encoded);
    System.out.println(decoded);
    
    
    str = "My test message 123456";
    
    encoded = Base64.encodeToString(str);
    System.out.println(encoded);
    
    decoded = Base64.decodeToString(encoded);
    System.out.println(decoded);
  }

}
   

It gives the following output,
QkUgVEhFIENPREVS
BE THE CODER

TXkgdGVzdCBtZXNzYWdlIDEyMzQ1Ng==
My test message 123456



 
  


  
bl  br