Code example for Cipher

Methods: doFinal, init

0
	} 
	public String ebcDecode(String encodeText){
		String str = null;
		try{ 
			SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "TripleDES");
			ci.init(Cipher.DECRYPT_MODE, keySpec);
			byte[] s = dbs64.decodeBuffer(encodeText);
			byte[] b = ci.doFinal(s);
			str = new String(b);
		}catch (Exception e){
			 
		} 
		return str;
	} 
	public static void main(String[] args){
		String key = "123456789ABCDEFG";
		String orgStr = "this is a test of 3des!测试项";
 
		TripleDESHelper helper = new TripleDESHelper(key);
		String encodeStr = helper.encode(orgStr);
		System.out.println("加密后的字符串为:"+encodeStr);