[英]Erlang: Problem with crypo:sha()
This works in my erlang shell: 这适用于我的erlang shell:
1> U = default_user_name().
2> crypto:start().
3> crypto:sha(U).
4> crypto:stop().
But when I compile this: 但是当我编译它时:
default_pw() ->
U = default_user_name(),
crypto:start(),
crypto:sha(U),
crypto:stop().
And execute it in the erlang shell, I get this: 并在erlang shell中执行它,我得到这个:
1> person:default_pw(). 1> person:default_pw()。
** exception error: bad argument **异常错误:错误的参数
in function port_control/3
called as port_control(crypto_drv04,5,<<"jDoe">>)
in call from crypto:control/2
Two questions: 两个问题:
1) What am I doing wrong? 1)我做错了什么?
2) It seems that I need to start and stop the crypto server. 2)似乎我需要启动和停止加密服务器。 But is there a better place to start and stop it in my application?
但是在我的应用程序中是否有更好的起点和停止位置?
Many thanks, 非常感谢,
LRP LRP
The error you are getting indicates that the crypto application was not started. 您收到的错误表明加密应用程序未启动。 An easy way to start it is just to add it as a parameter to
erl
like so: 一个简单的启动方法就是将它作为参数添加到
erl
如下所示:
$ erl -s crypto
I had a look at the current implementation of crypto and the past release notes for erlang and I came to the following conclusions (someone please correct me if I'm wrong): 我看了一下crypto的当前实现以及针对erlang的过去的发行说明,我得出了以下结论(如果我错了,有人请纠正我):
gen_server
template, and on 14B03 I don't need to start the application in order to make crypto:sha/1
work. gen_server
模板,而在14B03我不需要启动应用程序以使crypto:sha/1
工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.