-
Notifications
You must be signed in to change notification settings - Fork 0
/
bl.jsp
66 lines (50 loc) · 1.75 KB
/
bl.jsp
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
<html><head>
<%@ page import ="java.security.*"%>
<%@ page import ="javax.crypto.* " %>
<%@ page import ="java.util.Scanner" %>
</head>
<%
/* Scanner sc=new Scanner(System.in);
String s=sc.next();*/
String s="jitendra pinjertker";
byte[] plainText = s.getBytes("UTF8");
%>
<body>helllo
<%
//overal timer goes here
//generate keys
out.println( "\nStart generating DES key" );
// String ealgo=request.getParameter("ealgo");
String ealgo="AES";
KeyGenerator keyGen = KeyGenerator.getInstance(ealgo);
//get key peramerter here
int keyy =Integer.ParseInt(request.getParameter("keyy"));
//int keyy=128;
out.println(ealgo);
keyGen.init(keyy);
Key key = keyGen.generateKey();
out.println( "Finish generating DES key" );
//prepare stage
Cipher cipher = Cipher.getInstance(ealgo+"/ECB/PKCS5Padding");
out.println( "\n" + cipher.getProvider().getInfo() );
// start encryption timer
out.println( "\nStart encryption" );
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] cipherText = cipher.doFinal(plainText);
out.println( "Finish encryption: " );
out.println( new String(cipherText, "UTF8") );
// START TIMER
out.println( "\nStart decryption" );
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] newPlainText = cipher.doFinal(cipherText);
out.println( "Finish decryption: " );
//END TIMER
out.println( new String(newPlainText, "UTF8") );
//overall timer ends her
// calculate overall timer start-end;
//calculate encryption tiemr
//calaculate Decryption timer
/* */
%>
</body>
</html>