温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何用Java实现文件的加密与解密

发布时间:2020-06-01 15:39:43 来源:亿速云 阅读:943 作者:鸽子 栏目:编程语言

今天带来的java小项目实现文件加密解密,核心代码已展示出来
界面展示:

如何用Java实现文件的加密与解密

部分代码展示:
package wt.diy.encryption.gui;

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import wt.diy.encryption.service.ServiceContext;

public class Context {
ServiceContext service;
EncryptionFrame frame;
public Context(ServiceContext service) {
this.service = service;
}

public void setFrame(EncryptionFrame frame) {
    this.frame = frame;
}

public void excute(String source,String destiny, String key,JFrame frame) {
    File file = new File(destiny);

    if(!this.frame.getRadio().isSelected()&&file.exists()){
        JOptionPane.showMessageDialog(frame, “文件已经存在”);
        return ;
    }

    service.excute(source, destiny, key);
}

public void showMe(){
    frame.setVisible(true);
}

public String open(JFrame frame) {
    JFileChooser jfc = new JFileChooser();
    jfc.showOpenDialog(frame);
    File f = jfc.getSelectedFile();
    return f.getAbsolutePath();

}

}

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI