JSFiddle - React, Tailwind, and code Playground

JavaScript

function init() {
    var res = xor(cipher.toNumberArray(), [1, 2, 3]);
    document.write(res.toASCII());
};

function xor(cipher, key) {
    var res = [];
    for (var i = 0; i < cipher.length; i++) {
        res[i] = cipher[i] ^ key[i % key.length];
    }

    return res;
};

function fromChar() {

    var DIFF = 0;
    var PHASE = 0;
    var chars = [];
    var values = [];
    var char;
    var val;
    var min = Number.MAX_VALUE;
    var max = Number.MIN_VALUE;
    var map = {};
    var WLENGTH = 3;

    for (var i = 0; i < cipher.length - WLENGTH; i += WLENGTH) {
        val = parseInt(cipher.substring(i, i + WLENGTH));
        char = val.toUTF8Char();
        if (val > max) max = val;
        if (val < min) min = val;
        map[char] = (map[char] || 0) + 1;
        values.push(val);
        chars.push(char);
    }

    document.write(chars.join(" "));

    //document.write("<br>");
    //document.write("<br>");

    //parts.forEach(function (val) {
    //    document.write(String.fromCharCode(val) + " ");
    //});

    document.write("<br>");
    document.write("<br>");
    document.write("min: " + min);
    document.write("<br>");
    document.write("max: " + max);
    document.write("<br>");

    var pairs = [];

    for (var val in map) {
        pairs.push({
            value: val,
            count: map[val]
        });
    }

    pairs.sort(function (a, b) {
        return b.count - a.count;
    });

    pairs.forEach(function (item) {
        document.write(item.value + ": " + item.count);
        document.write("<br>");
    });
};

Number.prototype.toUTF8Char = function () {
    return '&#0' + this + ';';
};

String.prototype.groupBy = function (n) {
    var items = [];
    for (var i = 0; i < this.length - n; i += n) {
        items.push(this.substring(i, i + n));
    }

    return items;
};

String.prototype.toNumberArray = function () {
    var items = [];
    for (var i = 0; i < this.length; i++) {
        items.push(parseInt(this[i]));
   ...