Erlang的并行编译与加密
来源:互联网 发布:彩虹秒赞 v7源码 编辑:程序博客网 时间:2024/05/01 08:25
1.Erlang防止反编译 , 提供encrypt_debug_info 参数。
abstract_code(#compile{code=Code,options=Opts,ofile=OFile}) -> Abstr = erlang:term_to_binary({raw_abstract_v1,Code}, [compressed]), case member(encrypt_debug_info, Opts) of %%查找EmakeFile里是否带有这个参数。 例如 [encrypt_debug_info,{debug_info_key,"testkey"}]true -> case keyfind(debug_info_key, 1, Opts) of{_,Key} -> encrypt_abs_code(Abstr, Key); %%有的话当然直接去加密,erlang加密算法 des3_cbc , 3DES加密false -> %% Note: #compile.module has not been set yet. %% Here is an approximation that should work for %% all valid cases. %%如果没有则会去文件中查找,注释的代码在 beam_lib.erl、 %%crypto_key_fun_from_file() -> %% case init:get_argument(home) of %%init:get_argument(home) ,home目录查找,如果没有home那则在当前目录 %% {ok,[[Home]]} -> %% crypto_key_fun_from_file_1([".",Home]); %% _ -> %% crypto_key_fun_from_file_1(["."]) %% end. %% crypto_key_fun_from_file_1(Path) -> %%case f_p_s(Path, ".erlang.crypt") of %%默认查找.erlang.crypt %%{ok, KeyInfo, _} -> %% try_load_crypto_fun(KeyInfo); %% _ -> %% error %% end. Module = list_to_atom(filename:rootname(filename:basename(OFile))), Mode = proplists:get_value(crypto_mode, Opts, des3_cbc), case beam_lib:get_crypto_key({debug_info, Mode, Module, OFile}) oferror -> {error, [{none,?MODULE,no_crypto_key}]}; %%报错没有密钥Key -> encrypt_abs_code(Abstr, {Mode, Key}) end end;false -> {ok, Abstr} end.1. 可以在EmakeFile里指定debug_info_key
2.win下可在当前目录,或者我的文档目录创建 .erlang.crypt -> [{debug_info, des3_cbc, [], "li&^R^%0"}]. linux同理
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%分割线 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
并行编译
mmake.erl 首先要编译 mmake.erl
执行代码:
mmake.erl 目录自己定义
compile_mmake()->MMake = case filelib:wildcard("../src/mmake.erl") of[]-> case filelib:wildcard("../src/*/*/mmake.erl") of []-> [];[MMakeF]->MMakeFendend,case make:files([MMake],[{outdir, "../ebin"}]) oferror-> io:format("can not compile mmake.erl\n"),halt(1);_->okend.get_cpu_cores()->erlang:min(erlang:system_info(logical_processors)-1,1). compile_all(Options)->case mmake:all(get_cpu_cores(),[Options]) of up_to_date ->halt(0); error -> halt(1) end.compile_all()->code:add_patha("../ebin"),case mmake:all(get_cpu_cores()) of up_to_date ->halt(0); error -> halt(1) end.
感谢
http://erlangdisplay.iteye.com/blog/1264038
http://blog.csdn.net/phyzhou/article/details/8954931 两位作者。
0 0
- Erlang的并行编译与加密
- 在windows开发环境下写bat脚本实现对erlang项目的并行编译处理
- 关于erlang的编译
- erlang otp的编译
- Erlang的并行编程时代即将来临
- Erlang实现的矩阵相乘C=A*B单线程与并行多线程性能对比
- Windows下Erlang的编译与运行问题
- erlang的makefile编译问题
- Erlang中的并行编程
- Erlang 并行快速排序
- Erlang -奇偶并行排序
- Erlang简单并行服务器
- [Erlang]erlang与php的通信
- [Erlang]Erlang与C的节点通信
- 面向并行开发的“小众”语言——Erlang
- Erlang和Go的并行化concurrent比较
- Erlang 的安装配置,编译和运行
- centos编译erlang需要的一些库
- (windows,linux)DES加密解密
- 爱狗的法师打发斯蒂芬
- [Python]collections模块中的Counter类
- poj 2524 Ubiquitous Religions
- 阿斯顿发送到发撒的发松岛枫
- Erlang的并行编译与加密
- 六种PHP图片上传重命名方案研究与总结
- poj 2418 Hardwood Species(使用STL map)
- Android 中发一个intent启动多个应用,去掉always菜单技巧
- 阿斯顿发送到发十八式的发生大发
- 2014新生暑假个人排位赛04 C. 崔逗逗的难题
- MFC中客户区和非客户区概念的图示
- C++ 模板特化
- (转 推荐)c++ ActiveX基础1:使用VS2010创建MFC ActiveX工程项目