Spaces:
Running
Running
Create test/aaa.html
Browse files- test/aaa.html +56 -0
test/aaa.html
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script src="https://cdn.jsdelivr.net/npm/eruda@3.4.3/eruda.min.js"></script>
|
| 2 |
+
<script>
|
| 3 |
+
eruda.init();
|
| 4 |
+
|
| 5 |
+
</script>
|
| 6 |
+
<script src="https://downsub.com/js/main.dbfb0810053d0b1f3666.js">
|
| 7 |
+
</script>
|
| 8 |
+
|
| 9 |
+
<script>
|
| 10 |
+
// 1. CryptoJSを取得(グローバルに公開されているはず)
|
| 11 |
+
const CryptoJS = window.CryptoJS || Object.values(window).find(o => o && o.AES && o.enc && o.enc.Base64);
|
| 12 |
+
|
| 13 |
+
// 2. パスワード(コード内にあったもの)
|
| 14 |
+
const PASSWORD = "zthxw34cdp6wfyxmpad38v52t3hsz6c5";
|
| 15 |
+
|
| 16 |
+
// 3. カスタムフォーマットを再現
|
| 17 |
+
const customFormat = {
|
| 18 |
+
stringify: function(cipherParams) {
|
| 19 |
+
const obj = { ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64) };
|
| 20 |
+
if (cipherParams.iv) obj.iv = cipherParams.iv.toString(CryptoJS.enc.Hex);
|
| 21 |
+
if (cipherParams.salt) obj.s = cipherParams.salt.toString(CryptoJS.enc.Hex);
|
| 22 |
+
return JSON.stringify(obj);
|
| 23 |
+
},
|
| 24 |
+
parse: function(jsonStr) {
|
| 25 |
+
const obj = JSON.parse(jsonStr);
|
| 26 |
+
const cipherParams = CryptoJS.lib.CipherParams.create({
|
| 27 |
+
ciphertext: CryptoJS.enc.Base64.parse(obj.ct)
|
| 28 |
+
});
|
| 29 |
+
if (obj.iv) cipherParams.iv = CryptoJS.enc.Hex.parse(obj.iv);
|
| 30 |
+
if (obj.s) cipherParams.salt = CryptoJS.enc.Hex.parse(obj.s);
|
| 31 |
+
return cipherParams;
|
| 32 |
+
}
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
// 4. 暗号化関数
|
| 36 |
+
function $encode(text, password = PASSWORD) {
|
| 37 |
+
const encrypted = CryptoJS.AES.encrypt(JSON.stringify(text), password, {
|
| 38 |
+
format: customFormat
|
| 39 |
+
});
|
| 40 |
+
return encrypted.toString();
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// 5. 復号関数
|
| 44 |
+
function $decode(encryptedText, password = PASSWORD) {
|
| 45 |
+
const decrypted = CryptoJS.AES.decrypt(encryptedText, password, {
|
| 46 |
+
format: customFormat
|
| 47 |
+
});
|
| 48 |
+
return JSON.parse(decrypted.toString(CryptoJS.enc.Utf8));
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
// 6. テスト
|
| 52 |
+
const enc = $encode("https://youtu.be/rN7yhDl1cuk");
|
| 53 |
+
console.log("Encrypted:", enc);
|
| 54 |
+
const dec = $decode(enc);
|
| 55 |
+
console.log("Decrypted:", dec);
|
| 56 |
+
</script>
|