⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 AES C++加密解密和java版加密解密方法
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			e.printStackTrace();
		}
		
	}
	public String dec(String key ,byte[] aess) {
		System.out.println("======================================================");
		byte[] raw =key.getBytes();
		
		Cipher cipher =null;
		SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
		 try {
			cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			try {
				cipher.init(Cipher.DECRYPT_MODE, skeySpec);
			} catch (InvalidKeyException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchPaddingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
		
		// byte[] encrypted1 = hex2byte(sSrc);
		String doc = "";
		
			
				//byte[] bytOuta = cipher.doFinal(aess);
				System.out.println(aess.length);
				byte[] bytOut;
				bytOut = cipher.update(aess);
				doc = new String (bytOut);
				
				
				
			
			return doc;
	}
	   public static byte[] hex2byte(String strhex) {
	        if (strhex == null) {
	            return null;
	        }
	        int l = strhex.length();
	        if (l % 2 == 1) {
	            return null;
	        }
	        byte[] b = new byte[l / 2];
	        for (int i = 0; i != l / 2; i++) {
	            b[i] = (byte) Integer.parseInt(strhex.substring(i * 2, i * 2 + 2), 32);
	        }
	        return b;
	    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -