Ben yaşam dolu kale ile AES algoritması kullanarak şifreleme ve şifre çözme yapıyorumJ2ME AES Şifre çözme Hatası (org.bouncycastle.crypto.InvalidCipherTextException: ped blok bozuk)
Benim şifreleme ve şifre çözme tamamlandı ama bana benim düz hata veriyor
: metin boyutu olmayan deşifre verileripublic static boolean setEncryptionKey(String keyText)
{
byte[] keyBytes = keyText.getBytes();
key = new KeyParameter(keyBytes);
engine = new AESFastEngine();
cipher = new PaddedBufferedBlockCipher(engine);
return true;
}
Şifreleme veriyor hatta bazen daha büyük
olduğunu
public static String encryptString(String plainText)
{
byte[] plainArray = plainText.getBytes();
cipher.init(true, key);
byte[] cipherBytes = new byte[cipher.getOutputSize(plainArray.length)];
int cipherLength = cipher.processBytes(plainArray, 0, plainArray.length, cipherBytes, 0);
cipher.doFinal(cipherBytes, cipherLength);
String cipherString = new String(cipherBytes);
return cipherString;
}
Şifre çözme:
public static String decryptString(String encryptedText)
{
byte[] cipherBytes = encryptedText.getBytes();
cipher.init(false, key);
byte[] decryptedBytes = new byte[cipher.getOutputSize(cipherBytes.length)];
int decryptedLength = cipher.processBytes(cipherBytes, 0, cipherBytes.length, decryptedBytes, 0);
cipher.doFinal(decryptedBytes, decryptedLength);
String decryptedString = new String(decryptedBytes);
int index = decryptedString.indexOf("\u0000");
if (index >= 0)
{
decryptedString = decryptedString.substring(0, index);
}
return decryptedString;
}
Bu şifre çözme veriyor bana aşağıdaki hata
org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted
at org.bouncycastle.crypto.paddings.PKCS7Padding.padCount(+30)
at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(+190)
at com.NewCrypto.decryptString(NewCrypto.java:103)
at com.New_Midlet.startApp(New_Midlet.java:23)
at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:44)
at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:375)
at com.sun.midp.main.Main.runLocalClass(Main.java:477)
at com.sun.midp.main.Main.main(+80)
ne sorunu olabilir?
Karakter yerine hala bayt çıktıran herhangi bir base64 kodlayıcısı bence biraz aptalcadır. Birisi bir UTF-16 XML dosyasına aktarmayı denediğinde dehşeti zaten görebilirim. Ayrıca, varsayılan olandan başka herhangi bir base64 formunu desteklemiyor gibi görünmektedir. Mmm, belki kodlayıcımı da kullanmalıyım. –
@owlstead: Katılıyorum. Harder codec dizeleri, aptal commons stilini desteklediği gibi dizeleri de çıktıyacaktır. –