我一直在尝试使用Java加密PDF.到目前为止,我可以成功加密其他文件类型(.txt,.png等).当我使用PDF时,它会在我解密时打破信息.
这就是我用它来加密它:
public byte[] cryptograph(Key key, byte[] content){
Cipher cipher;
byte[] cryptograph = null;
try {
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
cryptograph = cipher.doFinal(content);
} catch (Exception e) {
e.printStackTrace();
}
return cryptograph;
}
Run Code Online (Sandbox Code Playgroud)
这要解密它:
public byte[] decrypt(Key key,byte[] textCryp){
Cipher cipher;
byte[] decrypted = null;
try {
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
decrypted = cipher.doFinal(textCryp);
} catch (Exception e) {
e.printStackTrace();
}
return decrypted;
}
Run Code Online (Sandbox Code Playgroud)
更新:
这是我用来读取文件的内容:
public byte[] getFile(){
byte[] content = null;
try {
InputStream is = …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用我在对话框中动态创建的数据表.每行都有一个复选框和一个编辑框.当我尝试使用DOJO对话框时,我可以更新与其关联的java对象中的属性,但是同样的按钮似乎没有以任何方式关闭对话框.
我也尝试过使用jquery对话框但是我遇到了部分更新的问题,我无法从对话框中触发任何服务器端事件.
我也尝试过使用重复控制,但它产生了其他问题.
当我看到关于它的一些论坛帖子时,使用java bean将代码的控制部分与视图分开似乎是一个非常好的主意,但现在它正在创建许多小问题,增加了开发时间.如果有人有其他方法,那么我尝试过的方法,我会非常感激.
与我的问题相关的一些问题是由于checkBox控件使用字符串true或false代替实际的布尔值.而这似乎使所有事件都无法在对话框中发挥作用.