This repo provides a few examples of how to securely store and retrieve a file using Nodejs and Cyclic.
- Clone repo
npm ci
- Add your secret file and .env to your
.gitignore
- Create a
.env
file if you don't have one withSECRET_PASSPHRASE=<some long and secret passphrase>
- Run:
npm run encrypt <YOUR_INPUT_FILENAME>
git add <YOUR_INPUT_FILENAME>.secure; git commit -m "Added secret file"
- Set an environment variable
SECRET_PASSPHRASE
with the value used to encrypt the file - Read the file in your server
const { decryptToString } = require('./secure-file.js')
...
const secureFileName = './account.json.secure'
const jsonStr = await decryptToString(secureFileName)
Coming soon!
Coming soon!