soiz1 commited on
Commit
f472903
·
verified ·
1 Parent(s): 3628cfa

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +76 -18
index.html CHANGED
@@ -1,19 +1,77 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="ja">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>文字列のエンコード/デコード</title>
7
+ <script>
8
+ function getXORValue() {
9
+ const xorInput = document.getElementById("xorValue");
10
+ return parseInt(xorInput.value) || 0; // 数値が無効な場合は0
11
+ }
12
+
13
+ function encodeString(str) {
14
+ const xorValue = getXORValue();
15
+ let encoded = str
16
+ .split("")
17
+ .map((char, ind) => {
18
+ if (ind % 2 !== 0) {
19
+ return String.fromCharCode(char.charCodeAt() ^ xorValue);
20
+ }
21
+ return char;
22
+ })
23
+ .join("");
24
+ return encodeURIComponent(encoded);
25
+ }
26
+
27
+ function decodeString(encodedStr) {
28
+ const xorValue = getXORValue();
29
+ let decodedStr = decodeURIComponent(encodedStr);
30
+ return decodedStr
31
+ .split("")
32
+ .map((char, ind) => {
33
+ if (ind % 2 !== 0) {
34
+ return String.fromCharCode(char.charCodeAt() ^ xorValue);
35
+ }
36
+ return char;
37
+ })
38
+ .join("");
39
+ }
40
+
41
+ function updateEncode() {
42
+ const inputStr = document.getElementById("inputStr").value;
43
+ const encodedStr = encodeString(inputStr);
44
+ document.getElementById("encodedStr").value = encodedStr;
45
+ }
46
+
47
+ function updateDecode() {
48
+ const encodedStr = document.getElementById("encodedStr").value;
49
+ const decodedStr = decodeString(encodedStr);
50
+ document.getElementById("inputStr").value = decodedStr;
51
+ }
52
+
53
+ window.onload = function() {
54
+ document.getElementById("inputStr").addEventListener("input", updateEncode);
55
+ document.getElementById("encodedStr").addEventListener("input", updateDecode);
56
+ document.getElementById("xorValue").addEventListener("input", () => {
57
+ updateEncode();
58
+ updateDecode();
59
+ });
60
+ }
61
+ </script>
62
+ </head>
63
+ <body>
64
+ <h1>文字列のエンコード/デコード</h1>
65
+ <div>
66
+ <h3>エンコード / デコード</h3>
67
+ <label for="xorValue">XOR値 (数値):</label>
68
+ <input type="number" id="xorValue" value="3" />
69
+ <br><br>
70
+ <label for="inputStr">元の文字列:</label><br>
71
+ <textarea id="inputStr" rows="4" cols="50"></textarea>
72
+ <br><br>
73
+ <label for="encodedStr">エンコードされた文字列:</label><br>
74
+ <textarea id="encodedStr" rows="4" cols="50"></textarea>
75
+ </div>
76
+ </body>
77
  </html>