nyx/commands/Owner/encrypt.js
2021-06-24 15:53:19 +08:00

40 lines
1 KiB
JavaScript

const { Client, Message, MessageEmbed } = require("discord.js");
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)}\`\`\``);
function encrypt(inp) {
var str = inp.split(""),
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) {
var str = inp.split(""),
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;
}
},
};