如今碰到這個問題: 在java中用AES加密,而後再node.js中解密 ,node.js 解密不出來 java
調研嘗試好久了,碰壁啊node
有牛人嗎?加密
java端: AES/ECB/PKCS5Paddingcode
public static String encryptAES(String content, String passwd) { byte[] key_bit =null; if(null == passwd){ key_bit = Utils.property("aes_key",null).getBytes(); }else{ key_bit = passwd.getBytes(); } try { Cipher aesECB = Cipher.getInstance("AES/ECB/PKCS5Padding"); SecretKeySpec key = new SecretKeySpec(key_bit, "AES"); aesECB.init(Cipher.ENCRYPT_MODE, key); byte[] result = aesECB.doFinal(content.getBytes()); String ret = new BASE64Encoder().encode(result); return ret; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } return null; }
node.js端解密ip