Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.test; import org.apache.commons.codec.binary.Base64; /** * * @author Administrator */ public class Base64Util { //*********** public static String encodeBase64(String message) { // byte[] result = Base64.encodeBase64(message.getBytes()); return new String(result); } //******************* //************ public static String decodeBase64(String message) { byte[] result = Base64.decodeBase64(message); return new String(result); } public static void main(String[] args) { // TODO code application logic here //******Testing****** String commonMessage = "Hello world"; //? String encodeMessage = encodeBase64(commonMessage); // System.out.println("?" + encodeMessage); String decodeMessage = decodeBase64(encodeMessage); // System.out.println("?" + decodeMessage); } }