คำถามติดแท็ก javax.crypto

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 …
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.