Created
April 27, 2019 14:55
-
-
Save TennousuAthena/7d2eda82000a026d04e84d9ebed7f98a to your computer and use it in GitHub Desktop.
🔒Base64 encode the whole folder!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const path = require('path') | |
const base64 = v => Buffer.from(v).toString('base64') | |
const work = map => { | |
let base64Map = map.map(base64) | |
let here = path.join(...map) | |
let there = path.join(...base64Map) | |
let stat = fs.statSync(here) | |
if (stat.isFile()) { | |
fs.writeFileSync(there, base64(fs.readFileSync(here))) | |
console.log('file', here) | |
} | |
if (stat.isDirectory()) { | |
fs.mkdirSync(there) | |
console.log('dir', here) | |
let dir = fs.readdirSync(here) | |
for (let i = 0; i < dir.length; i++) { | |
work([...map, dir[i]]) | |
} | |
} | |
} | |
work(['something...']) | |
//By https://github.com/c2ltb24zMDAw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment