Commit Graph

9 Commits (44f638e84d09037040893e81d813f5da7fb52e4a)

Author SHA1 Message Date
lu4p 199d24d24f
use fmt's %q to encode []byte literals
I now implemented and tested hex encoded strings, binary literals, and fmt.Sprintf("%q", data).
In the case of garble all produce the exact same binary size.

I decided to use %q because it is the simplest, leads to the smallest garbled code file size size
of the three, and is faster at compile time than binary literals.

It looks like:

    var ztN0xdMLL = garbleDecrypt([]byte("\xaf\xbd\x01\\&\x14\xab\xeb\x94\x10Q\xf2H#\xde\x17\a\x8f\x89MmZs\u0088\xcfw\xba?\x9e\xe1\x81\x1eպD\xe1@\xf2\x8d\xe3Ije\xca\bB\xbey\x8b"))

From the fmt docs:

    String and slice of bytes (treated equivalently with these verbs):
    [...]
    %q    a double-quoted string safely escaped with Go syntax

Fixes #40.
4 years ago
lu4p fdc7f97db8
use binary literals instead of hex strings
Fixes #40
4 years ago
lu4p 234174b418
don't obfuscate some literals which might break typechecking 4 years ago
lu4p 4c64b13506
make -seed=random use the same random seed for all packages
Otherwise, a different random seed per package will break imported names.
4 years ago
Daniel Martí a09b197fe2 remove the code to handle a nil file.Imports
I could not reproduce the supposed panic, even after I was able to reach
a nil x.Imports in that line in question with the modified test.
4 years ago
Daniel Martí 1bb85bbf9b simplify the code to obfuscate literals a bit 4 years ago
lu4p dd1fc4ed87
don't replace all consts with vars
In some cases, such as iotas or when constants are later required to be constants,
we could break compilation. Be more conservative.

Fixes #32.
4 years ago
Daniel Martí c6643d37f9 simplify and tidy up the string obfuscation code
Mainly removing unnecessary indentation and newlines, but also other
minor things like making error handling a bit more consistent.
4 years ago
lu4p 077d02d43a
add basic literal obfuscation, starting with strings
Fixes #16.
4 years ago