Files
ai-community/encrypt-page.js
qiudl 06f287b7af chore: enable auto-deploy for saltthing.top
- Added version comment for deployment tracking
- Auto-deploy configured on fnos with 5-minute sync interval

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 20:50:33 +10:30

43 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const crypto = require('crypto');
const fs = require('fs');
// 读取原始 HTML
const originalHtml = fs.readFileSync('nav-home.html', 'utf8');
// 提取 body 内容(从 <body> 到 </body>
const bodyMatch = originalHtml.match(/<body[^>]*>([\s\S]*)<\/body>/);
const bodyContent = bodyMatch ? bodyMatch[1] : '';
// 提取 style 内容
const styleMatch = originalHtml.match(/<style>([\s\S]*?)<\/style>/);
const styleContent = styleMatch ? styleMatch[1] : '';
// 加密函数 (AES-256-CBC与 CryptoJS 兼容)
function encrypt(text, password) {
// CryptoJS 使用 PBKDF2 派生密钥
const salt = crypto.randomBytes(8);
const key = crypto.pbkdf2Sync(password, salt, 1, 32, 'md5');
const iv = crypto.pbkdf2Sync(password, salt, 1, 16, 'md5');
// 使用 OpenSSL 兼容格式
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
let encrypted = cipher.update(text, 'utf8', 'base64');
encrypted += cipher.final('base64');
// 返回 "Salted__" + salt + encrypted 的 base64
const saltedPrefix = Buffer.from('Salted__');
const combined = Buffer.concat([saltedPrefix, salt, Buffer.from(encrypted, 'base64')]);
return combined.toString('base64');
}
const password = 'joylodging';
const encryptedStyle = encrypt(styleContent, password);
const encryptedBody = encrypt(bodyContent, password);
console.log('STYLE_LENGTH:', encryptedStyle.length);
console.log('BODY_LENGTH:', encryptedBody.length);
console.log('---ENCRYPTED_STYLE---');
console.log(encryptedStyle);
console.log('---ENCRYPTED_BODY---');
console.log(encryptedBody);