|
7836246 发表于 2024-3-20 20:10
多少米[ol]function decrypt(data, key) { const decryptionKey = key.split('').reverse().join(''); let decryptedData = CryptoJS.AES.decrypt({ ciphertext: data }, decryptionKey, { iv: decryptionKey, padding: CryptoJS.pad.Pkcs7 }, true, 'utf8'); return decryptedData.toString(CryptoJS.enc.Utf8);}function webpSupportCheck() { return new Promise((resolve, reject) => { const webpImage = new Image(); webpImage.onload = webpImage.onerror = function () { webpImage.onload = webpImage.onerror = null; resolve(webpImage.width === 1); }; webpImage.src = 'data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMw' + 'AgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA'; });}function loadImage(url, element, retries = 0) { const image = new Image(); image.crossOrigin = 'Anonymous'; image.onload = function () { if (retries > 0) { $(element).prev().find('.retry_img').remove(); } $(element).attr('src', image.src); $(element).removeClass('lazyload').addClass('loaded'); }; image.onerror = function () { if (retries { const dataHosts = lazyImage.getAttribute('data-img-hosts'); if (dataHosts) { const hosts = dataHosts.split(',').map(host => atob(host)); const url = new URL(lazyImage.getAttribute('data-original'), window.location.origin); url.hostname = hosts[Math.floor(Math.random() * hosts.length)]; loadImage(url.toString(), lazyImage); } else { loadImage(lazyImage.getAttribute('src'), lazyImage); } });}function main() { const key = 'my2secret'; const data = '...'; // This should be the encrypted data to be decrypted. const decryptedData = decrypt(data, key); if (webpSupportCheck()) { handleImages(); } else { // Fallback for non-WebP support }}main();[/ol]复制代码 |
|