在加密字符串时,它会'\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; }请有人指导我,我在这里做错了什么?提前致谢。
添加回答
举报
0/150
提交
取消