Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The following could be added to XStream.java to provide simple obfuscation of classes...I have done this to our implementation and it appears to work reasonably well.

      public void aliasFields(Class type) {
      Field[] fields = type.getDeclaredFields();

      StringBuffer sb = new StringBuffer();
      sb.append( 'a' );

      for ( int i = 0; i < fields.length; i++ )

      { Field field = fields[i]; aliasField( String.valueOf( sb.toString() ), type, field.getName() ); incrementAlias( sb ); }

      }

      private static char incrementAlias(char c)

      { return ( c == 'z' ? 'a' : ++c ); }

      private static void incrementAlias(StringBuffer buf) {

      char c;
      int i = buf.length() - 1;
      do {
      c = incrementAlias( buf.charAt( i ) );
      buf.setCharAt( i, c );
      if ( i == 0 && c == 'a' )

      { buf.insert( 0, 'a' ); break; }

      i--;
      }
      while ( c == 'a' );

      }

      1. Test.java
        2 kB
        Guilherme Silveira

        Issue Links

          People

          • Assignee:
            Unassigned
            Reporter:
            Justin Birch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: