stencyption
Version:
Military-grade JavaScript encryption with AES-256-GCM, polymorphic obfuscation, and anti-debugging protection. Each file gets unique encryption keys embedded in heavily obfuscated code.
85 lines (71 loc) • 2.37 kB
JavaScript
/**
* Simple Encryption Script
*
* Use this to encrypt your JavaScript files programmatically
*
* Usage:
* node encrypt.js <input-file> [output-file]
*
* Examples:
* node encrypt.js mycode.js
* node encrypt.js bot/login/login.js bot/login/login.encrypted.js
*/
const fs = require('fs');
const path = require('path');
const { Encryptor } = require('./src/index.js');
// Get input and output files from command line
const inputFile = process.argv[2];
const outputFile = process.argv[3];
if (!inputFile) {
console.log('❌ Error: No input file specified');
console.log('');
console.log('Usage:');
console.log(' node encrypt.js <input-file> [output-file]');
console.log('');
console.log('Examples:');
console.log(' node encrypt.js mycode.js');
console.log(' node encrypt.js bot/login/login.js bot/login/login.encrypted.js');
process.exit(1);
}
// Check if input file exists
if (!fs.existsSync(inputFile)) {
console.log(`❌ Error: File not found: ${inputFile}`);
process.exit(1);
}
// Determine output file name
let output = outputFile;
if (!output) {
const ext = path.extname(inputFile);
const base = path.basename(inputFile, ext);
const dir = path.dirname(inputFile);
output = path.join(dir, `${base}.encrypted${ext}`);
}
console.log('🔒 Encrypting:', inputFile);
console.log('⚙️ Processing...');
try {
// Read source code
const sourceCode = fs.readFileSync(inputFile, 'utf8');
// Encrypt
const encrypted = Encryptor.encrypt(sourceCode);
// Write encrypted file
fs.writeFileSync(output, encrypted, 'utf8');
const originalSize = sourceCode.length;
const encryptedSize = encrypted.length;
const ratio = ((encryptedSize / originalSize) * 100).toFixed(1);
console.log('');
console.log('✅ Encryption Complete!');
console.log('📁 Output:', output);
console.log('📊 Original:', originalSize, 'bytes');
console.log('📊 Encrypted:', encryptedSize, 'bytes');
console.log('');
console.log('⚠️ Important: Encrypted code requires "stencyption" package to run');
console.log(' Make sure stencyption is linked: npm link');
console.log('');
console.log('To run encrypted file:');
console.log(' node', output);
} catch (error) {
console.log('');
console.log('❌ Encryption failed:', error.message);
process.exit(1);
}