Skip to content

Commit

Permalink
大量更新
Browse files Browse the repository at this point in the history
FX.java 新增的动画效果
General 注释修改
  • Loading branch information
Lzhjk committed Dec 20, 2021
1 parent dd890e5 commit 3b2f8fc
Show file tree
Hide file tree
Showing 8 changed files with 443 additions and 87 deletions.
25 changes: 19 additions & 6 deletions Core/Crypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* 加解密类
*/
public class Crypto {
private String filePath; // 文件路径
private int depth = 5; // 加密深度(指对每个字节进行多少次操作)
private Random rd; // 随机数生成器
private String encryptedSuffix; // 加上crypt后的后缀名
private String sourceSuffix; // 原始后缀名
private boolean isEncrypt = true; // 当前要进行的是什么操作,true为加密,false为解密

// 用于进度显示
private double fileLength; // 文件总字节数
private double currentProgress; // 当前已处理的字节数

public double getFileLength() {
return fileLength;
}
public double getCurrentProgress() {
return currentProgress;
}

/**
* 导入参数:filePath:String
* <p>导入后立刻进行处理<br>
* 1、文件是否存在<br>
* 2、提取后缀名<br></p>
*
* @param _filePath 需要加解密的文件路径
*/
private void filePath(String _filePath) {
Expand Down Expand Up @@ -72,26 +81,30 @@ public float ReturnProgress() {
return (float) (currentProgress / fileLength);
}



/**
* Crypto类主要函数,传入参数并开始加解密操作
*
* @param _filePath 文件路径
* @param keyStr 作为密钥的字符串
* @throws Exception 可能有Null,FileNotFound
*/
public void Crypt(String _filePath, String keyStr) throws Exception{
// 录入参数
// 录入参数并进行相关处理
filePath(_filePath);
key(keyStr);
//
File sourceFile = new File(filePath);
if(!sourceFile.exists())
throw new NullPointerException();
File outputFile = null;
// 确认输出文件的文件名
// 确认输出文件的后缀名
if (isEncrypt) {
outputFile = new File(filePath.replace(sourceSuffix, "crypt" + sourceSuffix));
} else {
outputFile = new File(filePath.replace(encryptedSuffix, sourceSuffix));
}
//
// 创建各种流
InputStream in = null;
OutputStream out = null;
if (!outputFile.exists())
Expand Down
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: UI.Main
Main-Class: UI.MainUI

59 changes: 59 additions & 0 deletions UI/AboutWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package UI;

import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class AboutWindow extends JFrame{
AboutWindow(){
Font font = new Font("Microsoft YaHei", Font.PLAIN, 12);
// 读取About.txt内的说明信息
String strAbout = "";
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("Resource/About.txt"), StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
String tmp = "";
while ((tmp = reader.readLine()) != null) {
sb.append(tmp + "\n");
}
strAbout = sb.toString();
reader.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ioException) {
ioException.printStackTrace();
}
// 创建窗口
setTitle("关于");
JPanel panel = new JPanel(new BorderLayout());
JTextPane text = new JTextPane();
JScrollPane scrollPane = new JScrollPane(text);
panel.add(scrollPane, BorderLayout.CENTER);
text.setBackground(new Color(70, 70, 70));
text.setForeground(new Color(139, 150, 158));
text.setFont(font);
text.setEditable(false);
// 逐字输出关于信息
String finalStrAbout = strAbout;
new Thread(() -> {
for (int i = 0; i < finalStrAbout.length(); i++) {
try {
Thread.sleep(100);
text.setText(text.getText() + finalStrAbout.charAt(i));
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}).start();

setContentPane(panel);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setBounds(100, 100, 420, 500);
setVisible(true);
}

}
Loading

0 comments on commit 3b2f8fc

Please sign in to comment.