Code example for Cipher

Methods: doFinal, init

0
	 
	public String ebcEncode(String text){
		String str = null;
		try{ 
			SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "TripleDES");
			ci.init(Cipher.ENCRYPT_MODE, keySpec);
			byte[] b = ci.doFinal(text.getBytes());
			str = ebs64.encode(b);
		}catch (Exception e){
			e.printStackTrace();
		} 
		return str;
	} 
	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);