我如何使用AES加密整个字符串。我下面的代码只能加密到第一个被识别的空格。我该如何解决这个问题?谢谢。
SecretKeySpec key = new SecretKeySpec(salt.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
cipher.init(Cipher.ENCRYPT_MODE, key);
String result = new String(cipher.doFinal(message.getBytes()));
System.out.println("Encrypted:" + result);
编辑 天啊,我简直不敢相信,我怎么会错过这个 :( 这是因为我的扫描仪使用的是 next 而不是 nextLine... 真是太尴尬了,这个问题困扰了我一整天,直到现在我才想起来检查它。问题解决 :) 谢谢大家