Last active
February 25, 2021 23:12
-
-
Save hsorby/4a091a16f9851044742a5de593ba974b to your computer and use it in GitHub Desktop.
Simple node script to encrypt a token for use with libCellML website.
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
// Instructions: | |
// Create a temporary directory and inside that directory install crypto-js. | |
// Then run the encrpyt.js script with node and pass your token as the first argument. | |
// | |
// Terminal commands: | |
// mkdir tmp | |
// cd tmp | |
// npm i crypto-js | |
// curl -o encrypt.js https://gist.githubusercontent.com/hsorby/4a091a16f9851044742a5de593ba974b/raw/587338203ce7b9dcc0baf0894f3d1d547a37a7a4/encrypt.js | |
// node encrypt.js <your-token> | |
// | |
// Clearly <your-token> should be replaced with a token generated from your Github account. | |
var CryptoJS = require('crypto-js') | |
const args = process.argv.slice(2) | |
if (args.length > 0) { | |
// Encrypt | |
const ciphertext = CryptoJS.AES.encrypt(args[0], 'public-key').toString() | |
// Decrypt | |
const bytes = CryptoJS.AES.decrypt(ciphertext, 'public-key') | |
const originalText = bytes.toString(CryptoJS.enc.Utf8) | |
console.log('original: ', originalText) | |
console.log('encrypted: ', ciphertext) | |
console.log() | |
console.log('Copy and paste the line below into your .env.local file:') | |
console.log(`VUE_APP_ENCRYPTED_GITHUB_TOKEN=${ciphertext}`) | |
} else { | |
console.log('Usage: node encrypt.js <token>') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment