LoginSignup
1
1

More than 5 years have passed since last update.

crypto のメモ

Posted at

R16 で deprecated だった crypto:sha_* 等が削除、どうしよう、という件。

preprocessor は ifdef/ifndef なので、

#
 ERLANG_HOME ?= /opt/erlang/release/latest

 ERLANG_VER = $(shell $(ERLANG_HOME)/bin/erl -noshell -eval 'io:format("~s",[erlang:system_info(otp_release)]), halt()')

#
 REBAR_BIN  = rebar

 REBAR_ENV  =
 REBAR_ENV += PATH=$(ERLANG_HOME)/bin:$(PATH)

 REBAR_OPT  =
 REBAR_OPT += $(shell test $(ERLANG_VER) \< R16 && echo -DUSE_CRYPTO_DEPRECATED)

#
compile:
        @$(REBAR_ENV) $(REBAR_BIN) $(REBAR_OPT) $@
-ifndef(USE_CRYPTO_DEPRECATED).
hash(Binary, Type) ->
    L = [
         Binary
        ],
    F = fun(E,A) -> crypto:hash_update(A,E) end,
    crypto:hash_final(lists:foldl(F,crypto:hash_init(Type),L)).
-else.
hash(Binary, sha) ->
    L = [
         Binary
        ],
    F = fun(E,A) -> crypto:sha_update(A,E) end,
    crypto:sha_final(lists:foldl(F,crypto:sha_init(),L)).
-endif.

とか。

よく見たら、R15B03-1 には crypto:hash_init/1 はありましたね。。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1