-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyclass.java
79 lines (52 loc) · 1.9 KB
/
Myclass.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.InvalidKeyException;
import java.security.Key;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
public class Myclass {
public static void encryption()
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException
{
try
{
Cipher cipher=Cipher.getInstance("DES");
KeyGenerator keyg=KeyGenerator.getInstance("DES");
Key key=keyg.generateKey();
cipher.init(Cipher.ENCRYPT_MODE, key);
CipherInputStream cipt=new CipherInputStream(new FileInputStream(new File("/Users/saishmirajkar/Downloads/Orange and Pink Trendy Gradient Student Part-Time Product Marketing Manager Resume Presentation/1.jpg")), cipher);
FileOutputStream fileip=new FileOutputStream(new File("/Users/saishmirajkar/Downloads/Orange and Pink Trendy Gradient Student Part-Time Product Marketing Manager Resume Presentation/decrypt/encrypt.jpg"));
int i;
while((i=cipt.read())!=-1)
{
fileip.write(i);
}
cipher.init(Cipher.DECRYPT_MODE, key);
CipherInputStream ciptt=new CipherInputStream(new FileInputStream(new File("/Users/saishmirajkar/Downloads/Orange and Pink Trendy Gradient Student Part-Time Product Marketing Manager Resume Presentation/decrypt/encrypt.jpg")), cipher);
FileOutputStream fileop=new FileOutputStream(new File("/Users/saishmirajkar/Downloads/Orange and Pink Trendy Gradient Student Part-Time Product Marketing Manager Resume Presentation/decrypt/decrypt.jpg"));
int j;
while((j=ciptt.read())!=-1)
{
fileop.write(j);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
try
{
Myclass.encryption();
}catch(Exception e)
{
e.printStackTrace();
}
}
}