-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryptionTest.java
More file actions
43 lines (37 loc) · 1 KB
/
EncryptionTest.java
File metadata and controls
43 lines (37 loc) · 1 KB
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
43
/**
*
*/
package encryptfile;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author rutpatel
*
*/
public class EncryptionTest {
public static void main(String[] args) {
int count = 1;
File readFile = new File("EnDecryption/secretdata.txt");
File enFile = new File("EnDecryption/encrypteddata.txt");
try (FileInputStream fileInputStream = new FileInputStream(readFile);
FileOutputStream fileOutputStream = new FileOutputStream(enFile);) {
int data = fileInputStream.read();
while (data != (-1)) {
if ((data + count) > 122) {
fileOutputStream.write((data + count - 122) + 96);
} else {
fileOutputStream.write(data + count);
}
data = fileInputStream.read();
}
} catch (FileNotFoundException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
System.out.println(e.getMessage());
}
System.out.println("File Encrypted...");
}
}