Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nemson-source authored Mar 13, 2023
1 parent 930665c commit 5148809
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 0 deletions.
1 change: 1 addition & 0 deletions file_decoder.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node.exe file_decoder.js
37 changes: 37 additions & 0 deletions file_decoder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs');
const base64 = require('base64-js');
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});

console.log('Enter the input file (with the file path):');
readline.question('', (InputFile) => {
console.log('Enter the output folder (with a filename and extanmtion):');
readline.question('', (OutputFolder) => {
incode(InputFile, OutputFolder);
readline.close();
});
});

const incode = (InputFile, OutputFolder) => {

fs.readFile(InputFile, 'utf8', (err, data) => {
if (err) throw err;

const padding = '='.repeat((4 - data.length % 4) % 4);
const paddedBase64String = data + padding;

const bytes = base64.toByteArray(paddedBase64String);
const decodedString = new TextDecoder().decode(bytes);

fs.writeFile(OutputFolder, decodedString, (err) => {
if (err) throw err;
console.log(`Decoded string written to ${OutputFolder}`);
console.log(`this is the Decoded string: ${decodedString}`);
});
});
setTimeout(() => {
process.exit()
}, 10000)
}
1 change: 1 addition & 0 deletions file_incoder.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node.exe file_incoder.js
34 changes: 34 additions & 0 deletions file_incoder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');
const base64 = require('base64-js');
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});

console.log('Enter the input file (with the file path):');
readline.question('', (InputFile) => {
console.log('Enter the output folder (with a filename and extanmtion):');
readline.question('', (OutputFolder) => {
incode(InputFile, OutputFolder);
readline.close();
});
});

const incode = (InputFile, OutputFolder) => {

fs.readFile(InputFile, 'utf8', (err, data) => {
if (err) throw err;

const bytes = new TextEncoder().encode(data);
const base64String = base64.fromByteArray(bytes);

fs.writeFile(OutputFolder, `${base64String} \n file path and name: ${__filename}`, (err) => {
if (err) throw err;
console.log(`Encoded string written to ${OutputFolder}`);
console.log(`this is the incoded text: ${base64String}`)
});
});
setTimeout(() => {
process.exit()
}, 10000)
}
Binary file added node_modules.zip
Binary file not shown.
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"base64-js": "^1.5.1",
"fs": "^0.0.1-security",
"readline": "^1.3.0"
}
}
1 change: 1 addition & 0 deletions text_decoder.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node.exe text_decoder.js
34 changes: 34 additions & 0 deletions text_decoder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');
const base64 = require('base64-js');
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});

console.log('Enter the input text:');
readline.question('', (InputText) => {
console.log('Enter the output folder (with a filename and extanmtion):');
readline.question('', (OutputFolder) => {
incode(InputText, OutputFolder);
readline.close();
});
});


const incode = (InputText, OutputFolder) => {

const padding = '='.repeat((4 - InputText.length % 4) % 4);
const paddedBase64String = InputText + padding;

const bytes = base64.toByteArray(paddedBase64String);
const decodedString = new TextDecoder().decode(bytes);

fs.writeFile(OutputFolder, decodedString, (err) => {
if (err) throw err;
console.log(`Decoded string written to ${OutputFolder}`);
console.log(`this is the decoded text: ${decodedString}`)
});
setTimeout(() => {
process.exit()
}, 10000)
}
1 change: 1 addition & 0 deletions text_incoder.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node.exe text_incoder.js
30 changes: 30 additions & 0 deletions text_incoder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const base64 = require('base64-js');
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});

console.log('Enter the input text:');
readline.question('', (InputText) => {
console.log('Enter the output folder (with a filename and extanmtion):');
readline.question('', (OutputFolder) => {
incode(InputText, OutputFolder);
readline.close();
});
});

const incode = (InputText, OutputFolder) => {

const bytes = new TextEncoder().encode(InputText);
const base64String = base64.fromByteArray(bytes);

fs.writeFile(OutputFolder, base64String, (err) => {
if (err) throw err;
console.log(`Encoded string written to ${OutputFolder}`);
console.log(`this is the incoded text: ${base64String}`)
});
setTimeout(() => {
process.exit()
}, 10000)
}

0 comments on commit 5148809

Please sign in to comment.