-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrypt.Java
More file actions
38 lines (29 loc) · 791 Bytes
/
Crypt.Java
File metadata and controls
38 lines (29 loc) · 791 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
package CryptMachine;
import java.io.*;
public class Crypt {
private String path;
private File file;
private int deltaKey = 6;
public Crypt (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");
}
}
}
}