To shuffle the chars of the string st, I use std::shuffle and a random number generator, which is fed by a known seed. This is part of an encoder that, for simplicity, just shuffles the input.
The shuffled data is going to be sent to a decoder. At that side we don't have access to the original input, but the shuffled one.
How can I Unshuffle the string shuffledSt, using the same random number generator and the same seed, until I can obtain the original string st?
#include <random>
#include <algorithm>
int main (int argc, char* argv[])
{
    std::string st = "asdfgh";
    int seed = 1000;
    
    std::shuffle(st.begin(), st.end(), std::default_random_engine(seed));
    std::cerr << st << '\n';
    std::string shuffledSt = st;
    return 0;
}
 
    