小编sim*_*sew的帖子

在J2ME中加密和解密文件

我在使用充气城堡在J2ME中解密加密文件时遇到问题.我要做的是选择要加密的文件,写入加密文件并尝试将其解密回其原始形式(写入另一个文件以进行验证).

我在读取加密文件时遇到此错误.

Stack Trace : 
s: pad block corrupted
        at j.a(+219)
        at e.c(+38)
        at e.b(+30)
        at com.aaron.midlets.BluetoothServerMidlet.c(+134)
        at com.aaron.midlets.BluetoothServerMidlet.b(+161)
        at com.aaron.midlets.BluetoothServerMidlet.a(+67)
        at com.aaron.midlets.BluetoothServerMidlet.startApp(+105)
        at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:43)
        at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:374)
        at com.sun.midp.main.Main.runLocalClass(Main.java:466)
        at com.sun.midp.main.Main.main(Main.java:120)
Run Code Online (Sandbox Code Playgroud)

以下是我的代码的一部分:

private void createEncryptFile() {
    FileConnection fc = FileListingUtil.getFile("root1/", "test.encrypt");
    try {
        fc.create();
        readAndEncrypt();
    } catch (Exception e) {
    }
}

private void readAndEncrypt() {
    FileConnection fc = FileListingUtil.getFile("root1/", "test.original");
    FileConnection fc2 = FileListingUtil.getFile("root1/", "test.encrypt");

    try {
        InputStream test = fc.openDataInputStream();
        OutputStreamWriter output = new OutputStreamWriter(fc2.openOutputStream());

        int fileSize = …
Run Code Online (Sandbox Code Playgroud)

encryption file-io bouncycastle java-me

2
推荐指数
1
解决办法
1802
查看次数

标签 统计

bouncycastle ×1

encryption ×1

file-io ×1

java-me ×1