private static String scramble(final String name,int seed,final boolean enc){
  final char[] retString=name.toCharArray();
  final int len=name.length();
  int i, j;
  final char[] alphabet={'_','B','q','w','H','a','F','8','T','k','K','D','M','f','O','z','Q','A','S','x','4','V','u','X','d','Z','i','b','U','I','e','y','l','J','W','h','j','0','m','5','o','2','E','r','L','t','6','v','G','R','N','9','s','Y','1','n','3','P','p','c','7','g','-','C'};
  final int alphabetLen=alphabet.length;
  if (seed < 0) {
    seed=-seed;
  }
  seed=(seed > 0) ? seed%=alphabetLen : seed;
  if (seed == 0) {
    seed=1;
  }
  if (Cfg.DEBUG) {
    Check.asserts(seed > 0,"negative seed");
  }
  for (i=0; i < len; i++) {
    for (j=0; j < alphabetLen; j++) {
      if (retString[i] == alphabet[j]) {
        if (enc) {
          retString[i]=alphabet[(j + seed) % alphabetLen];
        }
 else {
          retString[i]=alphabet[(j + alphabetLen - seed) % alphabetLen];
        }
        break;
      }
    }
  }
  return new String(retString);
}

private static String scramble ( final String name , int seed , final boolean enc ) { final char [ ] retString = name . toCharArray ( ) ; final int len = name . length ( ) ; int i , j ; final char [ ] alphabet = { '_' , 'B' , 'q' , 'w' , 'H' , 'a' , 'F' , '8' , 'T' , 'k' , 'K' , 'D' , 'M' , 'f' , 'O' , 'z' , 'Q' , 'A' , 'S' , 'x' , '4' , 'V' , 'u' , 'X' , 'd' , 'Z' , 'i' , 'b' , 'U' , 'I' , 'e' , 'y' , 'l' , 'J' , 'W' , 'h' , 'j' , '0' , 'm' , '5' , 'o' , '2' , 'E' , 'r' , 'L' , 't' , '6' , 'v' , 'G' , 'R' , 'N' , '9' , 's' , 'Y' , '1' , 'n' , '3' , 'P' , 'p' , 'c' , '7' , 'g' , '-' , 'C' } ; final int alphabetLen = alphabet . length ; if ( seed < 0 ) { seed = - seed ; } seed = ( seed > 0 ) ? seed %= alphabetLen : seed ; if ( seed == 0 ) { seed = 1 ; } if ( Cfg . DEBUG ) { Check . asserts ( seed > 0 , "negative seed" ) ; } for ( i = 0 ; i < len ; i ++ ) { for ( j = 0 ; j < alphabetLen ; j ++ ) { if ( retString [ i ] == alphabet [ j ] ) { if ( enc ) { retString [ i ] = alphabet [ ( j + seed ) % alphabetLen ] ; } else { retString [ i ] = alphabet [ ( j + alphabetLen - seed ) % alphabetLen ] ; } break ; } } } return new String ( retString ) ; }
questa funzione scrambla / descrambla una stringa e ritorna il puntatore alla nuova stringa . il primo parametro e ' la stringa da de / scramblare , il secondo un byte di seed , il terzo se settato a true scrambla , se settato a false descrambla .
