Converted Bifid & moved over tests

This commit is contained in:
Matt C 2018-05-09 20:28:28 +01:00
parent f87666f659
commit 789ec94eff
4 changed files with 338 additions and 0 deletions

View file

@ -39,3 +39,23 @@ export function affineEncode(input, args) {
}
return output;
}
/**
* Generates a polybius square for the given keyword
*
* @private
* @author Matt C [matt@artemisbot.uk]
* @param {string} keyword - Must be upper case
* @returns {string}
*/
export function genPolybiusSquare (keyword) {
const alpha = "ABCDEFGHIKLMNOPQRSTUVWXYZ",
polArray = `${keyword}${alpha}`.split("").unique(),
polybius = [];
for (let i = 0; i < 5; i++) {
polybius[i] = polArray.slice(i*5, i*5 + 5);
}
return polybius;
}