%%% -------------------------------------------------------
%%% @author huangyongxing@yeah.net
%%% @doc
%%% beam key 加载与清理
%%% @end
%%% -------------------------------------------------------
-module(k).
-author("huangyongxing@yeah.net").
-export([
        l/0
        ,c/0
        ,h/0
    ]).

l() ->
    beam_lib:crypto_key_fun(fun crypto_fun/1).

c() ->
    beam_lib:clear_crypto_key_fun().

h() ->
    io:format("~ncommand:~nc() ---- clear key~nl() ---- load key~nh() ---- help~n").

crypto_fun(init)  -> ok;
crypto_fun(clear) -> ok;
crypto_fun({debug_info, Mode, Module, Filename}) ->
    case dik(Mode, Module, Filename) of
        error  -> {error, badarg};
        String -> String
    end;
crypto_fun(_) -> {error, badarg}.

dik(des3_cbc, _Module, _Filename) ->
    "eGJ342io.sdSDln9jAO";
dik(_, _, _) ->
    error.

