package com.amarsoft.mobile.web.security;

import com.amarsoft.mobile.web.security.imp.Des3Encryption;

/**
 * 通用含密钥的加密解密类
 * @author flian
 *
 */
public class CommonEncryptor {
	
	private String key = "Asdjflk%a2sdfjG#s$dfj6V@";
	private String iv = "14187630";
	
	public String encrypt(String text)throws Exception{
		//解密
		Des3Encryption de = new Des3Encryption();
		de.setEncryptKey(key.getBytes("UTF-8"));
		de.setIV(iv);
		byte[] result = de.encrypt(text.getBytes("UTF-8"));
		return Base64.encode(result);
	}
	
	public String dncrypt(String text)throws Exception{
		//解密
		Des3Encryption de = new Des3Encryption();
		de.setDecryptKey(key.getBytes("UTF-8"));
		de.setIV(iv);
		byte[] result = de.decrypt(Base64.decode(text));
		return new String(result,"UTF-8");
	}
}
