I've been facing a challenge with my project where the array "slicetable" keeps returning undefined, and I'm stuck on how to resolve this issue. My task involves creating an array of likelihoods for cryptographic key lengths and then splitting the text into individual strings of nth keys based on the length of the specified key. I've spent the past 4 hours trying to troubleshoot this, but I'm at a loss on where to start. If anyone has any advice on effective strategies for tackling problems like this or can offer assistance with this particular issue, I would greatly appreciate it - as I am still relatively inexperienced in this field.
function vigenerekey(text, max) {
// Standardize the text
text = text.split(" ").join("").toUpperCase();
// Obtain our list of key length probabilities
var probabilities = vigenerekeylength(text, max);
// Extend the Math.max to arrays
Array.max = function(array){
return Math.max.apply(Math, array);
};
// Find the position of the most probable key length
for (var d = 0; d <= 12; d++) {
if (probabilities[d] === probabilities.max) {
return;
}
}
// Slice the text into [d] parts (the length of the key)
var slicetable = ['','','','','','','','','','','','','','','','','','','','',''];
var chiresults = [];
for (var e = 0; e <= d; e++){
for (f = 0; f <= text.length; f++) {
if (f % e === 0) {
slicetable[e] += text.charAt(f);
}
}
return slicetable;
}
}