mirror of
https://github.com/JDM170/model_coder
synced 2025-12-10 05:57:19 +07:00
update index.js -> coder.js
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@ const chalk = require('chalk');
|
||||
const yargs = require('yargs/yargs')
|
||||
const { hideBin } = require('yargs/helpers')
|
||||
const fs = require('fs');
|
||||
const fse = require('fs-extra')
|
||||
// const fse = require('fs-extra')
|
||||
const path = require('path');
|
||||
const ora = require('ora');
|
||||
const glob = require("glob");
|
||||
@@ -56,21 +56,20 @@ getDirectories(argv.res, (err, res) => {
|
||||
// const key = crypto.createHash('sha256').update(argv.pass).digest('hex').toUpperCase();
|
||||
const key = crypto.createHash('md5').update(argv.pass).digest('hex').substring(0, 16);
|
||||
const data = fs.readFileSync(file);
|
||||
let array = [];
|
||||
let encoded = [];
|
||||
for (let i = 0; i < encodeSize; i++)
|
||||
array.push(tea.encode(data[i].toString(), key));
|
||||
encoded.push(tea.encode(data[i].toString(), key));
|
||||
|
||||
// Checking file for existing, if exists - deleting it
|
||||
try {
|
||||
fs.accessSync(newFilePath);
|
||||
//fs.rmSync(newFilePath);
|
||||
fs.ftruncateSync(newFilePath);
|
||||
fs.rmSync(newFilePath);
|
||||
} catch (err) {
|
||||
// console.log("access err: " + err);
|
||||
}
|
||||
|
||||
let fd = fs.openSync(newFilePath, 'a+'); // Open file
|
||||
fs.writeSync(fd, array.join(""), 0); // Writing encoded part in start of file
|
||||
fs.writeSync(fd, encoded.join(""), 0); // Writing encoded part in start of file
|
||||
fs.writeSync(fd, data, encodeSize, data.length - encodeSize); // Writing original part after encoded part
|
||||
fs.closeSync(fd); // Close file
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "MTA model encoder",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"main": "coder.js",
|
||||
"private": "true",
|
||||
"scripts": {
|
||||
"build": "pkg --target node16-win-x64 --compress GZip index.js"
|
||||
"buildc": "pkg --target node16-win-x64 --compress GZip coder.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
|
||||
Reference in New Issue
Block a user