Skip to content

Instantly share code, notes, and snippets.

@TennousuAthena
Created April 27, 2019 14:55
Show Gist options
  • Save TennousuAthena/7d2eda82000a026d04e84d9ebed7f98a to your computer and use it in GitHub Desktop.
Save TennousuAthena/7d2eda82000a026d04e84d9ebed7f98a to your computer and use it in GitHub Desktop.
🔒Base64 encode the whole folder!
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