肯定不对,安恒的题目的话,肯定是DASCTF{}
能提取一个这个出来,后面就不会了
[JavaScript] 纯文本查看 复制代码 async function pwdget(password) {
const encoder = new TextEncoder();
return window.crypto.subtle.importKey(
"raw",
encoder.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
);
}
function arrBfToB64(buffer) {
let binary = '';
const bytes = new Uint8Array(buffer);
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
function Encrypt() {
const plainText = "";
const password = "";
// const ivBase64 = "";
const iv = "";
const k = pwdget(password);
const key = window.crypto.subtle.deriveKey(
{ name: "PBKDF2", salt: new TextEncoder().encode("hello-dasctf"), iterations: 100000, hash: 'SHA-256' },
k,
{ name: "AES-GCM", length: 256 },
true,
["encrypt", "decrypt"]
);
const encoder = new TextEncoder();
const encodedText = encoder.encode(plainText);
const ciphertext = window.crypto.subtle.encrypt(
{ name: "AES-GCM", iv },
key,
encodedText
);
const base64Ciphertext = arrBfToB64(ciphertext);
} |