在加密字符串時,它會'\n'在字符串的末尾生成。這就是我進行加密的方式public static String encrypt(String plainText) throws Exception { byte[] tdesKeyData = Consts.getSecretKey().getBytes(); byte[] myIV = Consts.getInitializationVector().getBytes(); SecretKeySpec myKey = new SecretKeySpec(tdesKeyData, "DES"); IvParameterSpec ivspec = new IvParameterSpec(myIV); Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS7Padding"); cipher.init(Cipher.ENCRYPT_MODE, myKey, ivspec); byte[] plainTextBytes = plainText.getBytes("UTF-8"); byte[] buf = cipher.doFinal(plainTextBytes); byte[] base64Bytes = Base64.encode(buf, Base64.DEFAULT); String base64EncryptedString = new String(base64Bytes); return base64EncryptedString; }請有人指導(dǎo)我,我在這里做錯了什么?提前致謝。
添加回答
舉報
0/150
提交
取消