is there any algo which shuffles characters of a string such that every shuffles return a unique combination, yet can be shuffled back to the original string if we know how many time it was shuffled?
this is what i have so far, yet it s not what i wanted. It can shuffle only (n/2)+1 times after that it comes back to the original string
//scramble data systematicslly
function Scramble($contents)
{
    $fsize=strlen($contents);
    $m=intval($fsize/2);
    $buffer=$contents[$m];
    for($i = 1; $i < $fsize; $i++)
    { 
        if($i%2==0)
        {
            if($m+$i<=$fsize){$buffer.= $contents[$m+$i];}
            if($m-$i>=0){$buffer.= $contents[$m-$i];}
        }else
        {
            if($m+$i<=$fsize){$buffer.= $contents[$m+$i];}
            if($m-$i>=0){$buffer.= $contents[$m-$i];}
        }
    }    
    return $buffer;
}
 
     
    