[erlang-questions] Encrypt beam

Ulf Wiger (TN/EAB) <>
Thu Oct 11 11:09:50 CEST 2007

Roberto Saccon wrote:
> take a look at the beam_lib documentation
> http://erlang.org/doc/man/beam_lib.html

To clarify, beam_lib offers a way to encrypt the
'debug_info' (the source in parsed form) which can be
embedded in the beam file. This allows you to embed
debug_info even if you don't want to reveal the source
code. The encryption can be unlocked at runtime, so that
you can e.g. run profiling, etc. (perhaps eventually even
pretty-print the source and view it through distel?)

The beam code itself can of course be reverse-engineered.
The format isn't documented, but to get some idea of
what can possibly be extracted from beam code, you can view
the ASM code, from which the beam code is produced. How to
do this _is_ documented. Whether this is acceptable
obfuscation of your code, is of course up to you.

See an example at the end of this mail.

Ulf W

> On 10/11/07,  <> wrote:
>>  Hi guys !
>> I'm looking for a simple to encrypt ".beam" files to be sure that nobody
>> could reverse engineer them and got the original source (.erl).
>> For now, I'm just removing the debugging stuffs from them (.beam). Is it
>> enough for my problem ?
>> Thanks in advance
>> cheers
>> Y.
>> _______________________________________________
>> erlang-questions mailing list
>> http://www.erlang.org/mailman/listinfo/erlang-questions

= = = = = Example:

***** lc.erl:



lc1(List) ->
     L = [foo(X) ||
             X <- List,
             X > 17],

lc2(List1, List2) ->
     [foo({X, Y}) ||
         X <- List1,
         Y <- List2,
         X > Y].

foo(X) -> X.

erlc -W -S lc.erl

***** lc.S:

{module, lc}.  %% version = 0

{exports, [{lc1,1},{lc2,2},{module_info,0},{module_info,1}]}.

{attributes, []}.

{labels, 22}.

{function, lc1, 1, 2}.

{function, lc2, 2, 4}.

{function, foo, 1, 6}.

{function, module_info, 0, 8}.

{function, module_info, 1, 10}.

{function, '-lc2/2-lc$^0/1-0-', 2, 12}.

{function, '-lc2/2-lc$^1/1-1-', 4, 15}.

{function, '-lc1/1-lc$^0/1-0-', 1, 19}.

More information about the erlang-questions mailing list