闽公网安备 35020302035485号
const crypto = require('crypto');
// ML-KEM 示例
const { publicKey, privateKey } = crypto.generateKeyPairSync('ml-kem');
const { sharedSecret, ciphertext } = crypto.encapsulate(publicKey);
const decryptedSecret = crypto.decapsulate(privateKey, ciphertext);
// ML-DSA 示例
const signature = crypto.sign(null, Buffer.from('data'), privateKey);
const isValid = crypto.verify(null, Buffer.from('data'), publicKey, signature);
console.log(isValid); // true
这一功能为高安全需求的项目奠定未来基础。async function encryptData() {
const key = await crypto.subtle.generateKey({ name: 'AES-OCB', length: 256 }, true, ['encrypt']);
const encrypted = await crypto.subtle.encrypt({ name: 'AES-OCB', iv: crypto.getRandomValues(new Uint8Array(12)) }, key, new TextEncoder().encode('data'));
console.log(encrypted);
}
这为浏览器和 Node.js 应用提供更先进的加密选项。{
"main": "/path/to/script.js",
"output": "/path/to/blob.blob",
"execArgv": ["--no-warnings"],
"execArgvExtension": "cli"
}
这让 SEA 更易自定义运行行为。流中的 brotli 支持:新增 brotli 压缩流,优化数据传输。