4

[elixir! #0079] erlang 版本升级 22 -> 24

 2 years ago
source link: https://segmentfault.com/a/1190000040838878
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

[elixir! #0079] erlang 版本升级 22 -> 24

前几天升级了 elixir 版本, 今天想着干脆把 erlang 的版本也升级一下好了。听说 OTP24的性能有很大提升。升级之后一编译,果然又报了好些警告&错误,我们来一一解决。

** (UndefinedFunctionError) function :crypto.block_encrypt/3 is undefined or private, use crypto:crypto_one_time/4 or crypto:crypto_init/3 + crypto:crypto_update/2 + crypto:crypto_final/1 instead

首先是 :crypto 模块的api变了,变更的原因据说是OpenSSL 的 api变更。http://erlang.org/doc/apps/cr... 还好在网上搜索了一番,找到了解决的方法。

使用 :crypto.crypto_one_time 函数替代即可,最后一个参数是一个布尔值,true 代表加密, false 代表解密。具体用法还是看文档吧。

另外 :crypto.hmac 函数也没有了。统一改用 :crypto.mac(:hmac, ...)。具体参考函数文档。手动替换一下就可以了。

由于上面的这些原因,一些依赖库也用不了了。好在 elixir 社区常用的库维护都很频繁,到 hex.pm 上找到最近版本,更新一下就好了。

这样,一次愉快的 erlang 大版本升级就完成了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK