-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
161 lines (124 loc) · 3.5 KB
/
index.html
File metadata and controls
161 lines (124 loc) · 3.5 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Java Code Generator</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/java.min.js"></script>
<style>
body{
margin:0;
padding:20px;
font-family:Arial,sans-serif;
}
pre{
white-space:pre-wrap;
word-wrap:break-word;
}
</style>
</head>
<body>
<pre><code id="code" class="language-java"></code></pre>
<script>
function shiftChars(input, shift){
let output = "";
for(let i = 0; i < input.length; i++){
output += String.fromCharCode(
input.charCodeAt(i) + shift
);
}
return output;
}
function randomBase64Key(){
const bytes = new Uint8Array(16);
crypto.getRandomValues(bytes);
let binary = "";
bytes.forEach(b => binary += String.fromCharCode(b));
return btoa(binary).replace(/=/g,"");
}
function getParam(name){
return new URLSearchParams(location.search).get(name);
}
const string = getParam("string");
const code = document.getElementById("code");
if(!string){
const currentUrl =
location.origin +
location.pathname;
code.textContent =
`Exception in thread "main" java.lang.IllegalStateException: string must not be null
at com.jummania.link.Main.main(Main.java:10)
Usage: ${currentUrl}?string=your_encrypted_text_here`;
}else{
const base64Key = randomBase64Key();
const encKeyChars = shiftChars(base64Key, 1);
const shiftedEnc =
shiftChars(
btoa(string).replace(/=/g,""),
-1
);
const created =
new Date().toLocaleDateString();
code.textContent =
`public class Jummania {
public String getString() throws Exception {
return getString("${encKeyChars}", "${shiftedEnc}");
}
private String getString(
String secretKey,
String encryptedText
) throws Exception {
String string =
shiftChars(encryptedText, 1);
byte[] encryptedTextByte =
java.util.Base64
.getDecoder()
.decode(string);
javax.crypto.Cipher cipher =
javax.crypto.Cipher
.getInstance("AES");
cipher.init(
javax.crypto.Cipher.DECRYPT_MODE,
getSecretKey(secretKey)
);
return new String(
cipher.doFinal(encryptedTextByte)
);
}
private javax.crypto.SecretKey
getSecretKey(String key){
String string =
shiftChars(key, -1);
byte[] decodedKey =
java.util.Base64
.getDecoder()
.decode(string);
return new javax.crypto.spec.SecretKeySpec(
decodedKey,
0,
decodedKey.length,
"AES"
);
}
private String shiftChars(
String input,
int shift
){
StringBuilder result =
new StringBuilder();
for(char c : input.toCharArray()){
result.append(
(char)(c + shift)
);
}
return result.toString();
}
}`;
}
hljs.highlightAll();
</script>
</body>
</html>