-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathFindIt.java
More file actions
36 lines (27 loc) · 842 Bytes
/
FindIt.java
File metadata and controls
36 lines (27 loc) · 842 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
/*
Kasun De Zoysa @ UCSC
*/
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.util.Base64;
public class FindIt {
public static void main(String args[]) throws Exception {
//Complete this programme to decrypt the
//following base64 encoded cipher text
String cText="A1TEAJWqY8c=";
//Decode the cyber text
byte[] ciphertext = Base64.getDecoder().decode(cText);
//This ramdom generate is used to get key and iv
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed("1234".getBytes());
byte[] k = new byte[128/8];
sr.nextBytes(k);
SecretKeySpec key = new SecretKeySpec(k,"AES");
//Set a IV
//decryption pass
System.out.println("Plain text length: "+plainText.length);
String s= new String(plainText);
System.out.println("plain text: " + s);
}
}