Skip to content

Commit 491fd6c

Browse files
authored
First commit
1 parent 565c589 commit 491fd6c

17 files changed

+312
-0
lines changed

functions/additionalProcessing.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
additionalCringe: () => {
3+
console.log("Performing additional processing...");
4+
console.log("Just a second.....")
5+
return new Promise((resolve, reject) => {
6+
resolve(); // just resolve.
7+
});
8+
},
9+
};

functions/calculateDigest.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const crypto = require("crypto");
2+
3+
module.exports = {
4+
IdkHowToCalculateImFive: (message) => {
5+
const hash = crypto.createHash("sha256");
6+
hash.update(message);
7+
return hash.digest("hex"); // hehex
8+
},
9+
};

functions/decryptMessage.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const crypto = require("crypto");
2+
const confeg = {
3+
encryptionAlgorithm: "aes-256-cbc",
4+
secretMessage: "Hello World!",
5+
secretPassphrase: "SPINACH",
6+
};
7+
8+
module.exports = {
9+
vzlomPopki: (encryptedData, key, iv) => {
10+
return new Promise((resolve, reject) => {
11+
const decryptionCipher = crypto.createDecipheriv(
12+
confeg.encryptionAlgorithm,
13+
key,
14+
iv
15+
);
16+
let decryptedMessage = decryptionCipher.update(
17+
encryptedData,
18+
"hex",
19+
"utf8"
20+
);
21+
decryptedMessage += decryptionCipher.final("utf8"); // FINAL?
22+
resolve(decryptedMessage);
23+
});
24+
},
25+
};

functions/encryptMessage.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const crypto = require("crypto");
2+
const confeg = {
3+
encryptionAlgorithm: "aes-256-cbc",
4+
secretMessage: "Hello World!",
5+
secretPassphrase: "SPINACH",
6+
};
7+
8+
module.exports = {
9+
HackTheUniverse: (message, key, iv) => {
10+
return new Promise((resolve, reject) => {
11+
const encryptionCipher = crypto.createCipheriv(
12+
confeg.encryptionAlgorithm,
13+
key,
14+
iv
15+
);
16+
let encryptedMessage = encryptionCipher.update(message, "utf8", "hex"); // hehe.
17+
encryptedMessage += encryptionCipher.final("hex");
18+
resolve(encryptedMessage);
19+
});
20+
},
21+
};

functions/generateKeyPairPromise.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const crypto = require("crypto");
2+
3+
module.exports = {
4+
shizanutiyCode: (options) => {
5+
return new Promise((resolve, reject) => {
6+
crypto.generateKeyPair(
7+
"rsa",
8+
options,
9+
(generateKeyPairError, publicKey, privateKey) => {
10+
if (generateKeyPairError) {
11+
console.error("Errar generatinjg key pair........:", generateKeyPairError);
12+
reject(generateKeyPairError);
13+
return;
14+
}
15+
resolve({
16+
publicKey,
17+
privateKey,
18+
});
19+
}
20+
);
21+
});
22+
},
23+
};

functions/generateRandomIV.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { RAAAAHHH } = require("./getRandomBytes");
2+
3+
module.exports = {
4+
PUPOKBOBRA: () => {
5+
return RAAAAHHH(16);
6+
},
7+
}; // RAHAHAHAHAHAHAHAHAHAH

functions/generateRandomNumbers.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
randomizer: () => {
3+
return new Promise((resolve, reject) => {
4+
const numbers = [];
5+
for (let i = 0; i < 10; i++) {
6+
const random = Math.floor(Math.random() * 1000);
7+
numbers.push(random);
8+
}
9+
resolve(numbers.sort((a, b) => b - a)); // THAT'S LIKE A SENIOR TASK
10+
});
11+
},
12+
};

functions/getRandomBytes.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const crypto = require("crypto");
2+
3+
module.exports = {
4+
RAAAAHHH: (size) => {
5+
return new Promise((resolve, reject) => {
6+
crypto.randomBytes(size, (randomBytesError, salt) => {
7+
if (randomBytesError) {
8+
console.error("Error generating salt. WANNA SUGAR? ", randomBytesError);
9+
reject(randomBytesError);
10+
return;
11+
}
12+
resolve(salt);
13+
});
14+
});
15+
},
16+
};
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { additionalCringe } = require("./additionalProcessing");
2+
const { shoEto } = require("./performTimeConsumingTask");
3+
4+
module.exports = {
5+
esheOdinCringe: (publicKey, privateKey) => {
6+
console.log("Performing additional validation... THAT'S IMPORTANT!!!");
7+
return new Promise((resolve, reject) => {
8+
const isValid = publicKey.length > 100 && privateKey.length > 100;
9+
if (!isValid) {
10+
console.log("Validation failed!!!!!!!!!1111");
11+
resolve();
12+
} else {
13+
shoEto();
14+
additionalCringe().then(resolve);
15+
}
16+
});
17+
},
18+
};

functions/performTimeConsumingTask.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
shoEto: () => {
3+
console.log("Performing time-consuming task.....................");
4+
for (let i = 0; i < 1000000000; i++) {}
5+
},
6+
};

functions/printDecryptedMessage.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
AHAHAHAHAPython: (message, isValid) => {
3+
return new Promise((resolve, reject) => {
4+
if (isValid) {
5+
setTimeout(() => {
6+
console.log(message);
7+
resolve();
8+
}, 1000);
9+
} else {
10+
console.log("INVALLIIID SIGNATURE :SKULL:");
11+
resolve();
12+
}
13+
});
14+
},
15+
};

functions/scryptPromise.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const crypto = require("crypto");
2+
3+
module.exports = {
4+
iWokeUpInANewBuggati: (passphrase, salt, keylen) => {
5+
return new Promise((resolve, reject) => {
6+
crypto.scrypt(passphrase, salt, keylen, (scryptError, key) => {
7+
if (scryptError) {
8+
console.error(
9+
"AAAAAAHHHHHHH ERROR BROOHHH generating key...sad..",
10+
scryptError
11+
);
12+
reject(scryptError);
13+
return;
14+
}
15+
resolve(key); // to find the discriminant of a quadratic equation, which can be made from the letters of the word "key", you should use the discriminant formula: Discriminant (D) = b^2 - 4ac, where a, b and c are the coefficients of the quadratic equation.
16+
});
17+
});
18+
},
19+
};

functions/shuffleArray.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
shufleArraray: (array) => {
3+
return new Promise((resolve, reject) => {
4+
for (let i = array.length - 1; i > 0; i--) {
5+
const j = Math.floor(Math.random() * (i + 1));
6+
[array[i], array[j]] = [array[j], array[i]];
7+
}
8+
resolve(array);
9+
});
10+
},
11+
}; // What a save!

functions/signData.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const crypto = require("crypto");
2+
3+
module.exports = {
4+
signPetition: (data, privateKey) => {
5+
return new Promise((resolve, reject) => {
6+
const signature = crypto.createSign("RSA-SHA256");
7+
signature.update(data);
8+
const generatedSignature = signature.sign(privateKey, "hex"); // #ffffff
9+
resolve(generatedSignature);
10+
});
11+
},
12+
};

functions/verifySignature.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const crypto = require("crypto");
2+
3+
module.exports = {
4+
WhyNot: (data, publicKey, signature) => {
5+
return new Promise((resolve, reject) => {
6+
const signatureVerification = crypto.createVerify("RSA-SHA256"); // RSAA SHA SHA SHAAAA
7+
signatureVerification.update(data);
8+
const isSignatureValid = signatureVerification.verify(
9+
publicKey,
10+
signature,
11+
"hex"
12+
);
13+
resolve(isSignatureValid);
14+
});
15+
},
16+
};

index.js

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const { RAAAAHHH } = require("./functions/getRandomBytes");
2+
const { iWokeUpInANewBuggati } = require("./functions/scryptPromise");
3+
const { PUPOKBOBRA } = require("./functions/generateRandomIV");
4+
const { IdkHowToCalculateImFive } = require("./functions/calculateDigest");
5+
const { HackTheUniverse } = require("./functions/encryptMessage");
6+
const { shizanutiyCode } = require("./functions/generateKeyPairPromise");
7+
const { signPetition } = require("./functions/signData");
8+
const { WhyNot } = require("./functions/verifySignature");
9+
const { vzlomPopki } = require("./functions/decryptMessage");
10+
const { AHAHAHAHAPython } = require("./functions/printDecryptedMessage");
11+
const { randomizer } = require("./functions/generateRandomNumbers");
12+
const { shufleArraray } = require("./functions/shuffleArray");
13+
const { esheOdinCringe } = require("./functions/performAdditionalValidation");
14+
15+
const confeg = {
16+
encryptionAlgorithm: "aes-256-cbc",
17+
secretMessage: "Hello World!", // THAT'S HEELLOOO WORLD OMGGG
18+
secretPassphrase: "SPINACH", // spinach.
19+
};
20+
21+
const main = async () => {
22+
try {
23+
const salt = await RAAAAHHH(16); // 16 because on August 16, 2017 I didn't get a spoonful of soup in my mouth so I write in JavaScript
24+
const key = await iWokeUpInANewBuggati(confeg.secretPassphrase, salt, 32); // That soup was not saltyIWOKEUPINANEWBUGGATTIII
25+
const iv = await PUPOKBOBRA(); // no questions.
26+
const encryptedMessage = await HackTheUniverse(
27+
confeg.secretMessage,
28+
key,
29+
iv
30+
);
31+
const digest = IdkHowToCalculateImFive(encryptedMessage);
32+
const keyPair = await shizanutiyCode({
33+
modulusLength: 2048,
34+
publicKeyEncoding: {
35+
type: "spki",
36+
format: "pem",
37+
},
38+
privateKeyEncoding: {
39+
type: "pkcs8",
40+
format: "pem",
41+
},
42+
});
43+
const generatedCucumber = await signPetition(digest, keyPair.privateKey);// why not?
44+
const KakoyToCringe = `${encryptedMessage}:${salt.toString("hex")}:${iv.toString("hex")}:${generatedCucumber};`;
45+
const [encryptedData, saltData, ivData, signatureData] = KakoyToCringe.split(":");
46+
const isSignatureValid = await WhyNot(
47+
digest,
48+
keyPair.publicKey,
49+
signatureData
50+
);
51+
const decryptedMessage = await vzlomPopki(
52+
encryptedData,
53+
key,
54+
Buffer.from(ivData, "hex")
55+
);
56+
await esheOdinCringe(keyPair.publicKey, keyPair.privateKey);
57+
await AHAHAHAHAPython(decryptedMessage, isSignatureValid);
58+
} catch (error) {
59+
console.error("bro an error occurred:", error);
60+
}
61+
};
62+
63+
const FINALLY = async () => {
64+
console.log("Performing VERY complex calculations...");
65+
const randamNumbers = await randomizer(); // aron don don
66+
const shafffledNumbers = await shufleArraray(randamNumbers);
67+
const filturedNambers = shafffledNumbers.filter((num) => num % 2 === 0);
68+
const sum = filturedNambers.reduce((total, num) => total + num, 0);
69+
const isEven = sum % 2 === 0;
70+
if (isEven) {
71+
await main();
72+
} else {
73+
console.log("Sorry, the sum of the filtered numbers is odd. WHY.");
74+
}
75+
};
76+
77+
FINALLY();

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"dependencies": {
3+
"crypto": "^1.0.1"
4+
},
5+
"name": "helloworld",
6+
"version": "1.0.0",
7+
"main": "index.js",
8+
"devDependencies": {},
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"keywords": [],
13+
"author": "",
14+
"license": "ISC",
15+
"description": ""
16+
}

0 commit comments

Comments
 (0)