-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecrypt.java
More file actions
42 lines (33 loc) · 910 Bytes
/
Decrypt.java
File metadata and controls
42 lines (33 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package CryptMachine;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Decrypt {
private String path;
private File file;
private int deltaKey = 6;
public Decrypt (String path, File file) {
this.path = path;
this.file = file;
}
public String getPath() {
return path;
}
public void processFile () throws IOException {
try(BufferedReader bf = new BufferedReader ( new FileReader(this.path));
FileWriter fw = new FileWriter (this.file, true)) {
String reader;
while((reader = bf.readLine()) != null) {
char symbol [] = reader.toCharArray();
char encryptSymbol[] = new char [symbol.length];
for (int i =0 ;i<symbol.length; i++) {
encryptSymbol[i] = (char)(symbol[i] - deltaKey);
fw.write(encryptSymbol[i]);
}
fw.write("\n\r");
}
}
}
}