As far as your specific shuffling test, The default shuffle will swap every element with another randomly chosen element in the sequence. It is literally impossible for "RANDOM" to be shuffled into "RANDOM" regardless; the R, for example, will be randomly swapped with one of the other letters, and cannot swap with itself so will always be moved, as will all the other letters. The only way the same letter can appear in the same location in the input and output is if it appears more than once and is swapped with one of that letters other appearances.
The C++ Shuffle Function I am using I have detected where characters shuffled end up back in their starting position. This is why i had to implement a key strength routine to my code to give choice of strong or weaker keys. Having a choice of strong or weaker keys allows for all keys to be considered unknown to whether a string or weaker key was used when shuffling the information. I ran a smaller test program that wrote to file keys that were strongest and there are quite a few keys that are weaker with 2 characters or more remaining in their starting position such as
ABCDEF shuffled to FEDCBA is every character is no longer in its original position in the string, so the array that has these characters for substitution if the message to be scrambled up is BAD FACE it would be EFC AFDB
But in a weaker shuffle where a weaker long long int key is used to seed the random shuffle if ABCDEF was shuffled as ABCDFE now the message to scramble is seen in the output saved to file as BAD EACF and BAD is plain as day and it could then be assumed that BAD are 3 letters that werent shuffled out of their original placement within the starting string. So the ( A ) in EACF is very probable the A of the next word.
Here is more on the Random_Shuffle function:
http://www.cplusplus.com/reference/algorithm/random_shuffle/Randomly rearrange elements in range
Rearranges the elements in the range [first,last) randomly.
The function swaps the value of each element with that of some other randomly picked element. When provided, the function gen determines which element is picked in every case. Otherwise, the function uses some unspecified source of randomness.
This function states that it carries out this action as a for each character
:
The function swaps the value of each element with that of some other randomly picked element
Initially I thought just as you stated that RANDOM would be a scramble where every character was placed different from its original position, but I think the issue is in the fact that if there are 15 characters, it is doing a for each character shuffle stepping say left to right.
So you can have this happen below:
ABCDEFGHIJKLMNO = Starting string
Random_Shuffle then swaps first character or element A with C
CBADEFGHIJKLMNO
Random_Shuffle then swaps next character B with O
COADEFAHIJKLMNB
Random_Shuffle then swaps next character A with C ( *Here is how A and C get back to their original place within the string )
AOCDEFAHIJKLMNB
It will perform this for 15 iterations for 15 characters and the worst case scenario would be that the shuffle placed everything back into its original order of
ABCDEFGHIJKLMNO
However its more probable that a few characters are in their original location and this makes for an long long int value that is used as a key value for the seed of the random_shuffle to be a weaker key since this seed value shuffles the string in a way that some characters are not moved out of their original place within the string.
When I first read up on this random_shuffle function having never used it until this program as for in the past I have made my own shuffler function vs using a built in function, I read this as the fact that every character would be shuffled so that none would ever end up back in their original placement, but then i got thinking about it and realized that its probably not testing in any way to avoid a character from going back to its original place within the string. So I needed to test for this. To me it was important for it to be able to make for weaker keys, otherwise if only strong keys (strong seeds) were used, then you could throw out a very large list of keys as not in use for scrambling data. So for the fact that it can shuffle in a way that characters can make their way back to their original position and choice to use a strong or weaker key and no one knowing if you used a stronger or weaker key, you then wouldnt be excluding a whole bunch of keys from use.
I dont have the source code on me to list here the test program, I have it at home and i can share it here so you can see how its placing characters back into their original location. I have a loop that you tell it how many times to run say for 10,000 times and it steps through each seed value and performs a string compare between the original static string and that of the output on a character for character ( element for element ) basis between the original and the shuffled. It then has flags that when x-many matches are found to display that iteration of the 10,000 to display what seed values match to that weak key with say 4 characters that end up back in their original location after the random_shuffle has completed.
The random_shuffle initially I thought was playing 52 pickup
in which throw a deck of cards into the air and pick the cards back up and there is the chance that you could pick them up and have 2 through ACE in the 4 suits perfect as the day you first opened the pack of cards, but from testing with it it seems like its doing a 1 for 1 for as many characters are in that string so its running left to right with substituting a 1 for 1 until end of the string which would use less memory at the cost of clock cycles. But with as fast as computers are today extra clock cycles for a program like this is just about unnoticeable. Its too bad there is no way to pause the random_shuffle function through its execution in which you can step the clock cycle for the program and see the inner workings of it to see if its 52 card pick up or a 1 for 1 which I think its a 1 for 1 left to right possibly. The seed to the generator in a 52 pickup would be the trajectory of the cards and where they landed and to which order they are picked up in a very bent analogy that sounds godlike quantum magic knowing exactly as something would fall and land based on all parameters of the environment in which that one seed value alone is the fate of all cards in the 52 pickup as to how they will reenter the deck form in known order based on the seed alone and rules that dont change so outcome is always the same based on that one single long long int.
Size of long long types is 8 bytes
Signed long long min: -9,223,372,036,854,775,808 max: 9,223,372,036,854,775,807
Unsigned long long min: 0 max: 18,446,744,073,709,551,615
Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).
Quite a number of keys to pick from with the Long Long Int seed.
And I have only played around with the first Billion of them and that took a FX-8350 8-Core 4Ghz almost a week to complete testing full tilt 125 Million keys per core with 8 copies of my program running testing keys on a Windows 7 64-bit based system with 8GB RAM.
The computer became a good loud fan noisy space heater for that week since I dont have liquid cooling, just the stock aluminum block heatsink and it levels out at 63C with CPU fan on maximum RPMs.