The Problem
Only HEX values of 10 through ff work. I can not assign 00 through 0f as keys; they get dropped from it seems. My understanding is that these values would require quotes to work, but that doesn't seem to be the case. I even read this article and it didn't help. How can I assign these HEX values as array keys?
Background
What I am trying to do is create a substitution array that holds HEX values that will be used to substitute other HEX values. Confusing? Let me show you:
This HEX string comes in (Text that was changed to HEX): 2a2b
My goal is then to use the substitution array to change this into another hex string like so: 1fa9
The fastest way I can think to do this is to assign HEX values to the array keys this way I can look up the key that matches the hex value and substitute it right away for its value like so:
// I'm working with chunks of 25 fyi
for (var i = 0; i < 25; i++) {
dataChunck[i] = substitueArray[dataChunck[i]];
}
The Rest of My Code
This has been cut down to just what you need. hexValues is an array of HEX values 00 through ff.
// Start at array index 1 because be defined and saved 0 already
for (var x = 1; x < 256; x++) {
if (counter > 255) {
break; // We now have all 256 HEX values, stop
}
// We want to allow 256 as an option so go 1 higher (257)
if (sub > 0 && sub < 257) {
// If the number (HEX value) is not already saved save it
if (sboxValues.indexOf(hexValues[sub - 1]) < 0) {
// RIGHT HERE IS THE PROBLEM!!!
// This assigns a HEX value as the key and saves sub to it
// sub as you can see gets converted to HEX as its saved
sboxValues[hexValues[x]] = hexValues[sub - 1];
counter++;
} else {
// Glitch: That number has been saved, redo this round
// Keep x on track so we don't accidently reuse it
x--;
}
sub += num; // Move on to new number
} else {
// Removed. You don't need to see this code
// Keeps x on track so we don't accidently reuse it
}
}