Skip to content

Commit d48095b

Browse files
author
Christian Ipanaque
committed
[enhancement]: add files to generate encrypted mailing address
1 parent 2cdd3a4 commit d48095b

9 files changed

+711
-0
lines changed

.gitignore

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
private.txt
2+
private.key
3+
result.json
4+
result.csv
5+
6+
.vscode
7+
8+
# Logs
9+
logs
10+
*.log
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
lerna-debug.log*
15+
.pnpm-debug.log*
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
*.lcov
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
bower_components
41+
42+
# node-waf configuration
43+
.lock-wscript
44+
45+
# Compiled binary addons (https://nodejs.org/api/addons.html)
46+
build/Release
47+
48+
# Dependency directories
49+
node_modules/
50+
jspm_packages/
51+
52+
# Snowpack dependency directory (https://snowpack.dev/)
53+
web_modules/
54+
55+
# TypeScript cache
56+
*.tsbuildinfo
57+
58+
# Optional npm cache directory
59+
.npm
60+
61+
# Optional eslint cache
62+
.eslintcache
63+
64+
# Optional stylelint cache
65+
.stylelintcache
66+
67+
# Microbundle cache
68+
.rpt2_cache/
69+
.rts2_cache_cjs/
70+
.rts2_cache_es/
71+
.rts2_cache_umd/
72+
73+
# Optional REPL history
74+
.node_repl_history
75+
76+
# Output of 'npm pack'
77+
*.tgz
78+
79+
# Yarn Integrity file
80+
.yarn-integrity
81+
82+
# dotenv environment variable files
83+
.env
84+
.env.development.local
85+
.env.test.local
86+
.env.production.local
87+
.env.local
88+
89+
# parcel-bundler cache (https://parceljs.org/)
90+
.cache
91+
.parcel-cache
92+
93+
# Next.js build output
94+
.next
95+
out
96+
97+
# Nuxt.js build / generate output
98+
.nuxt
99+
dist
100+
101+
# Gatsby files
102+
.cache/
103+
# Comment in the public line in if your project uses Gatsby and not Next.js
104+
# https://nextjs.org/blog/next-9-1#public-directory-support
105+
# public
106+
107+
# vuepress build output
108+
.vuepress/dist
109+
110+
# vuepress v2.x temp and cache directory
111+
.temp
112+
.cache
113+
114+
# Docusaurus cache and generated files
115+
.docusaurus
116+
117+
# Serverless directories
118+
.serverless/
119+
120+
# FuseBox cache
121+
.fusebox/
122+
123+
# DynamoDB Local files
124+
.dynamodb/
125+
126+
# TernJS port file
127+
.tern-port
128+
129+
# Stores VSCode versions used for testing VSCode extensions
130+
.vscode-test
131+
132+
# yarn v2
133+
.yarn/cache
134+
.yarn/unplugged
135+
.yarn/build-state.yml
136+
.yarn/install-state.gz
137+
.pnp.*

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Get a free JavaScript sticker
2+
3+
1.

decrypt.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const NodeRSA = require("node-rsa");
2+
const fs = require("fs");
3+
4+
(async () => {
5+
const keyData = fs.readFileSync("private.key", "utf8");
6+
const test = fs.readFileSync("stickers/christianengineer.txt", "utf8");
7+
8+
const key = NodeRSA();
9+
key.importKey(keyData);
10+
11+
const decrypted = key.decrypt(test, "utf8");
12+
13+
console.log(decrypted);
14+
})();

index.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const inquirer = require("inquirer");
2+
const chalk = require("chalk");
3+
const NodeRSA = require("node-rsa");
4+
const fs = require("fs");
5+
6+
(async () => {
7+
const answers = await inquirer.prompt([
8+
{
9+
type: "input",
10+
name: "name",
11+
message: "Enter your full name",
12+
},
13+
{
14+
type: "input",
15+
name: "street",
16+
message: "Street address",
17+
},
18+
{
19+
type: "input",
20+
name: "street2",
21+
message: "Suite or Apt # (optional)",
22+
},
23+
{
24+
type: "input",
25+
name: "city",
26+
message: "City",
27+
},
28+
{
29+
type: "input",
30+
name: "state",
31+
message: "State/Region",
32+
},
33+
{
34+
type: "input",
35+
name: "zip",
36+
message: "Postal Code",
37+
},
38+
{
39+
type: "input",
40+
name: "country",
41+
message: "Country",
42+
},
43+
{
44+
type: "input",
45+
name: "notes",
46+
message: "Any special notes?",
47+
},
48+
]);
49+
50+
const keyData = fs.readFileSync("public.key", "utf8");
51+
52+
const key = NodeRSA();
53+
key.importKey(keyData);
54+
55+
const encrypted = key.encrypt(answers, "base64");
56+
57+
console.log(chalk.yellow("------ copy below ------"));
58+
console.log(chalk.green(encrypted));
59+
console.log(chalk.yellow("------ copy above ------"));
60+
61+
console.log(`
62+
${chalk.blueBright(
63+
"Step 1:"
64+
)} Copy the green encrypted text above - it's your encrypted mailing address.
65+
${chalk.blueBright("Step 2:")} Create a new file in ${chalk.bgBlue(
66+
"stickers/<your-github-username>.txt"
67+
)}. Paste in the green text.
68+
${chalk.blueBright("Step 3:")} Submit a pull request on Github.
69+
${chalk.blueBright("Step 4:")} Check your mailbox in a few weeks!
70+
${chalk.bgKeyword("orange")(
71+
chalk.black(" Pull Request Requirements ")
72+
)} Your pull request should only contain 1 new file! Which is the stickers/<your-github-username>.txt file.
73+
`);
74+
})();

keygen.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const NodeRSA = require("node-rsa");
2+
const fs = require("fs");
3+
4+
(async () => {
5+
const key = new NodeRSA();
6+
key.generateKeyPair();
7+
fs.writeFileSync(`public.key`, key.exportKey("public"));
8+
fs.writeFileSync(`private.key`, key.exportKey("private"));
9+
})();

0 commit comments

Comments
 (0)