I've got a HashMap
which stores the frequencies of each letter in a block of ciphertext, in the form of Character, Integer. The map is then sorted into a LinkedHashMap
by most frequent descending.
I then compare these frequencies to a known list of letter frequencies to try and guess what the cipher letter is. The problem I've run into is if 2 or more letters occur the same number of times.
For example, if we take:
E T A O I
as the 5 most common letters desc and then letter frequencies in the cipher text:
D=30 B=25 I=22 G=19 H=17
then it would be fair to assume D
maps to E
as it is the most common, followed by B
to T
etc.
If the letter frequencies are:
D=30 B=25 I=22 G=22 H=22
It is unclear whether I
, G
or H
should map to A
as they are all the next most common after B
.
I'm a little stuck and need a way of creating a set of char arrays with each permutation of the frequency list. Something like this would be needed to be output in char arrays:
DBIGH
DBIHG
DBGIH
DBGHI
DBHIG
DBHGI
Any help would be much appreciated