java web与android互通的aes算法
####Java实现代码 //可自定义保证16btye即可 private static final byte[] IV = {16, 26, -35, 23, 34, 125, -5, -4, -8, -9, -15, -78, 90, -8, -99, 100}; public static byte[] encrypt(String content, String password) { try { SecretKeySpec key = getKey(password);//根据密码生成key if(key == null){ return null; } Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");// 创建密码器"算法/模式/补码方式" byte[] byteContent = content.getBytes("utf-8"); cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(IV));//初始化,使用该模式,需要一个向量16byte的IvParameterSpec byte[] result = cipher.doFinal(byteContent);// 加密 return result; } catch