nyx/unused/commands/Owner/encrypt.js

40 lines
1,017 B
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
module.exports = {
name: "code",
Owner: true,
run: async (client, message, args) => {
const encrypted = encrypt(args.slice(0).join(" "));
message.channel.send(`\`\`\`${encrypted}\`\`\``);
message.channel.send(`\`\`\`${decrypt(encrypted)}\`\`\``);
const str;
2021-06-12 12:53:51 +02:00
function encrypt(inp) {
let str = inp.split(""),
2021-06-12 12:53:51 +02:00
out = "";
str.forEach((c, i) => {
if (c == " ") {
out += " ";
} else if (i % 3 == 0) {
out += String.fromCharCode(c.charCodeAt(0) + 3);
} else {
out += String.fromCharCode(c.charCodeAt(0) - 2);
}
});
return out;
}
function decrypt(inp) {
let str = inp.split(""),
2021-06-12 12:53:51 +02:00
out = "";
str.forEach((c, i) => {
if (c == " ") {
out += " ";
} else if (i % 3 == 0) {
out += String.fromCharCode(c.charCodeAt(0) - 3);
} else {
out += String.fromCharCode(c.charCodeAt(0) + 2);
}
});
return out;
}
},
};