/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	private static String byteToHex(byte[] bytes) {
		StringBuilder sb = new StringBuilder();
	    for (byte b : bytes) {
	        sb.append(String.format("%02X ", b));
	    }
	    return sb.toString();
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		final byte[] SALT= { (byte) 0x21, (byte) 0x21, (byte) 0xF0, (byte) 0x55, 
							 (byte) 0xC3, (byte) 0x9F, (byte) 0x5A, (byte) 0x75 };
		final int   ITERATION_COUNT = 31;
        KeySpec keySpec = new PBEKeySpec("test".toCharArray(), SALT, ITERATION_COUNT);
        AlgorithmParameterSpec paramSpec = new PBEParameterSpec(SALT, ITERATION_COUNT);

        SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);

		Cipher c = Cipher.getInstance("PBEWithMD5AndDES");
		c.init(Cipher.ENCRYPT_MODE, key, paramSpec);
		
		byte[] ct = c.doFinal("test".getBytes("UTF-8"));

        System.out.println(byteToHex(ct));
	}
}