【问题标题】:How to install OTP erlang-crypto library如何安装 OTP erlang-crypto 库
【发布时间】:2017-05-12 07:50:54
【问题描述】:

我想从源代码构建 erlang。构建后我尝试检查加密库,如下所示:

$erl -env ERL_LIBS $ERL_LIBS:/path/to/couchdb/lib -couch_ini -s crypto
1> crypto:md5_init().
<<>>

我已经预料到了

1> crypto:md5_init().
<<1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,
  16,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>

在构建 erlang 之前,我已经安装了 openssl,openssl-dev。

【问题讨论】:

    标签: erlang couchdb


    【解决方案1】:

    crypto:md5_init() 返回值没有任何问题。这是一个代表 Erlang 运行时内部数据结构的“魔术二进制”示例。如果您按照文档说明使用它,它会完美运行:

    1> C = crypto:md5_init().
    <<>>
    2> C2 = crypto:md5_update(C, "some data").
    <<>>
    3> crypto:md5_final(C2).
    <<30,80,33,10,2,2,73,127,183,155,195,139,106,222,108,52>>
    

    这个例子来自 Erlang 19。如果我们回到 18.3 或更早版本,我们会得到:

    1> C = crypto:md5_init().
    <<1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,
      16,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>
    2> C2 = crypto:md5_update(C, "some data").
    <<1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,
      16,72,0,0,0,0,0,0,0,115,111,109,101,32,...>>
    3> crypto:md5_final(C2).
    <<30,80,33,10,2,2,73,127,183,155,195,139,106,222,108,52>>
    

    请注意,这两个示例的最终 MD5 结果是相同的。

    【讨论】:

      猜你喜欢
      • 2017-12-20
      • 2014-08-10
      • 2017-11-24
      • 2016-11-07
      • 2018-07-12
      • 2019-05-10
      • 1970-01-01
      • 2011-04-12
      • 2011-12-12
      相关资源
      最近更新 更多