Numbers and VBA constants

The camouflage of numbers and VBA constants complicates tracking of the source–code.

This function, however, only processes numbers which do NOT appear within character strings.
To camouflage these, activate the processing level "Encrypting strings".

Camouflaging of numbers

All explicitly specified integer values ??are replaced by constants with codename.
Their declaration is additionally camouflaged by the subtraction
of a decimal and a hexadecimal value.

Example: x = x + 1
x = x + iRwlNzrcUwQcQjmX

Const iRwlNzrcUwQcQjmX = 9488 – &H250F 'gives = 1

Excluded from this are:

– floating point and hexadecimal numbers

– values outside the LONG range (–2,147,483,648 ... 2,147,483,647)

– numbers in instructions for conditional compilation (#Const, #If, #ElseIf)

– syntactically required numbers in statements such as
  "On Error GoTo 0", "Option Base 0|1" etc.

Numbers that occur in constant declarations are only camouflaged
if they are declared in the form

"Const XXX [As YYY] = NNN"

and NNN is a value within the LONG range.
The camouflage takes place in this case directly in the declaration
by the subtraction of a decimal and a hexadecimal value:

"Const XXX [As YYY] = aaa – bbb"

if absolute value greater or equal

This option should be activated only if with the compilation of the processed project
one of the below mentioned error appears (out of memory, module too large).

However, the vast amount of numbers in a source code is not really relevant
for a camouflage, because they do not provide meaningful information.

This particularly concerns mostly small numbers.

Example: x = x + 1
If y = 0 Then ...
For z = lngMax To 0 Step –2 ...

By setting a minimum value for the absolute amount these little numbers
are excluded from the camouflage, which often leads to a significant reduction
of the affected module or a reduction of memory requirements.

This setting applies ONLY integer values within the LONG range!

Camouflaging of VBA constants

All VBA constants (e.g. vbYes, True/False) are replaced with camouflaged constants.

Example: If intResult = vbYes Then ...
If intResult = alKAsjbniQflXH Then ...

The declaration each camouflaged constant is additionally disguised.

Hereto CrunchCode builds a sum or difference from a decimal and a hexadecimal value.
Thus, the original value is no longer visible in the entire project.

Example: If intResult = vbYes Then ... ("vbYes" represents the value "6")
Const alKAsjbniQflXH = &H7129 – 28963 (=6)
... |
If intResult = alKAsjbniQflXH Then ...


The camouflage of numbers and VBA constants has no affect on the performance
of the camouflaged source–code, because only constants are exchanged mutually.

In addition, every declared identifier needs memory space.
Explicit numerical values and VBA constants are usually used often,
so that the same number of camouflaged constants must be declared.

With very big projects, this can lead to compilation problems.
The following error messages (and others) may result:

  Out of memory (Error 7)

There are too many identifiers (thus also constants).
It is therefore not possible to compile the source–code
(exceeds the 64K segment limit of the internal identifier table).

  Module is too large

The total code of the module has become too large
and will have to be split into two (or more) modules.
CrunchCode tries to avoid this problem but is unable to determine
when this point will be reached.

If this occurs, do not camouflage numbers and/or VBA constants
or at least set a minimum value for the to be camouflaged numbers (see above).