4
เนื่องจากบล็อกสุดท้ายไม่ได้รับการหุ้มอย่างถูกต้อง
ฉันกำลังพยายามใช้อัลกอริทึมการเข้ารหัสที่ใช้รหัสผ่าน แต่ฉันได้รับข้อยกเว้นนี้: javax.crypto.BadPaddingException: เนื่องจากบล็อกสุดท้ายไม่ได้รับการหุ้มอย่างถูกต้อง ปัญหาอาจเกิดจากอะไร? นี่คือรหัสของฉัน: public class PasswordCrypter { private Key key; public PasswordCrypter(String password) { try{ KeyGenerator generator; generator = KeyGenerator.getInstance("DES"); SecureRandom sec = new SecureRandom(password.getBytes()); generator.init(sec); key = generator.generateKey(); } catch (Exception e) { e.printStackTrace(); } } public byte[] encrypt(byte[] array) throws CrypterException { try{ Cipher cipher …