-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.js
More file actions
35 lines (29 loc) · 1.08 KB
/
decrypt.js
File metadata and controls
35 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const fs = require('fs');
const path = require('path');
function decodeFolderContentsSync(basePath, outputDir) {
const items = fs.readdirSync(basePath);
for (const item of items) {
const itemPath = path.join(basePath, item);
const decodedItemPath = path.join(outputDir, Buffer.from(item, 'base64').toString());
const itemStats = fs.statSync(itemPath);
if (itemStats.isDirectory()) {
try {
fs.mkdirSync(decodedItemPath, { recursive: true });
decodeFolderContentsSync(itemPath, decodedItemPath);
} catch (err) {
console.error('Error creating directory:', err);
}
} else if (itemStats.isFile()) {
try {
const base64Contents = fs.readFileSync(itemPath, 'utf8');
const decodedContents = Buffer.from(base64Contents, 'base64').toString();
fs.writeFileSync(decodedItemPath, decodedContents);
} catch (err) {
console.error('Error decoding or writing file:', err);
}
}
}
}
const inputFolder = './data';
const outputFolder = './clear';
decodeFolderContentsSync(inputFolder, outputFolder);