package com.javahonk.dao;

import org.apache.tomcat.util.codec.binary.Base64;

/**
 * @author Java Honk
 *
 */
public class Base64PasswordEncrypter {

	public static void main(String[] args) {
		String password = "admin";
		System.out.println(base64Encode(password));		

	}
	
	/**
	 * @param token
	 * @return encoded
	 */
	public static String base64Encode(String token) {
		
		byte[] encodedBytes = Base64.encodeBase64(token.getBytes());
		return new String(encodedBytes);
	}

	/**
	 * @param token
	 * @return
	 */
	public static String base64Decode(String token) {
		byte[] decodedBytes = Base64.decodeBase64(token);
	    return new String(decodedBytes);
	}	

}
