yWorks / yGuard

The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts

Home Page:https://yworks.github.io/yGuard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to generate pseudorandom name mappings for package, class

kal-an opened this issue · comments

commented

I've set scramble = "true", it worked only on fields, methods.
Example from yguard.log:

<package name="....." map="z"/>
  <class name="...." map="z"/>
  <field class="...." name="log" map="&#x005374;"/>
  <field class="...." name="userService" map="&#x0688;"/>
  <field class="...." name="storage" map="&#x006fdc;"/>

So, packages, classes had the same map name, like z, a, b

There seems to be a misunderstanding about the behavior of scramble.
If you have a jar with classes that are not obfuscated and you run yGuard multiple times on that jar with scramble="false", yGuard will produce the same obfuscated names in each run. If the input stays the same, the output does as well.
If you use scramble="true", running yGuard multiple times on the same input jar will produce different obfuscated names for each run. The output differs even if the input stays the same.
scramble does not prevent yGuard from using "simple" names like a, b, ... when renaming.
Please see also Add randomized mapping scramble for more information on scramble.

If you want to change the type of obfuscated names that are generated by yGuard, please use yGuard's property element and set a naming-scheme and language-conformity of your choice.

commented

Thank you for your response.
The problem is that I am using the POM example on my project.
https://github.com/yWorks/yGuard/blob/master/examples/processing/pom.xml

yGuard Bytecode Obfuscator, v4.0.0,
MacOS 10.14.6,
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing),
Maven

When used <rename scramble = "true»…> as a result I get as above in my first example (single lowercase characters, only for packages and classes map's)

When used <rename scramble = «false»…> as a result I get single caps, example: A, Z, B for different classes, packages, methods, fields.

When launched
……
Annotation-specified bean name 'b' for bean class […..] conflicts with existing, non-compatible bean definition of same name and class
…..

I've set a naming-scheme and language-conformity, too.
I would like to use automatic name generation.

Did you actually read what @thomasbehr wrote? Did you try the alternatives? Do you understand that the effect you were looking for is just a coincidence?

That said, you probably should not be generating random names automatically when using JavaBeans - they work using reflection and randomly generating names is not a good idea when reflection is part of the equation.