Skip to content

Instantly share code, notes, and snippets.

@thecodemedia
Created May 24, 2021 04:58
Show Gist options
  • Save thecodemedia/04373426608b0f108588bbcf36d77d3c to your computer and use it in GitHub Desktop.
Save thecodemedia/04373426608b0f108588bbcf36d77d3c to your computer and use it in GitHub Desktop.
// шифруем сообщение
output = "";
for (i = 0; i < input.length; i++) {
// берём цифровое значение очередного символа в сообщении и ключе
inp = input.charCodeAt(i);
k = key.charCodeAt(i);
// и применяем к ним исключающее или — XOR
output += String.fromCharCode(inp ^ k);
}
// выводим результат шифрования
console.log("Результат работы алгоритма ↓");
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment