Here you can find the source of encryptUrlEncode(String dataPassword, String cleartext)
public static String encryptUrlEncode(String dataPassword, String cleartext) throws Exception
//package com.java2s; //License from project: Apache License import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64; import java.net.URLEncoder; public class Main { private static final byte[] ENCRYPT_IV = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; private static final String CHARSET = "UTF-8"; public static String encryptUrlEncode(String dataPassword, String cleartext) throws Exception { return URLEncoder.encode(encrypt(dataPassword, cleartext), CHARSET); }/*from w ww. j a v a 2s .co m*/ public static String encrypt(String dataPassword, String cleartext) throws Exception { IvParameterSpec zeroIv = new IvParameterSpec(ENCRYPT_IV); SecretKeySpec key = new SecretKeySpec(dataPassword.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv); byte[] encryptedData = cipher.doFinal(cleartext.getBytes(CHARSET)); return new String(Base64.encodeBase64(encryptedData)); } }