Просмотр исходного кода

Merge pull request #239 from galdor/switch-to-crypto-mac

switch to crypto:mac/4 since crypto:hmac/3 is deprecated
Sergey Prokhorov 4 лет назад
Родитель
Сommit
80d6b0eb43
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      src/epgsql_scram.erl

+ 10 - 0
src/epgsql_scram.erl

@@ -116,8 +116,18 @@ hi1(Str, U, Hi, I) ->
     Hi1 = bin_xor(Hi, U2),
     hi1(Str, U2, Hi1, I - 1).
 
+-ifdef(OTP_RELEASE).
+-if(OTP_RELEASE >= 23).
+hmac(Key, Str) ->
+    crypto:mac(hmac, sha256, Key, Str).
+-else.
 hmac(Key, Str) ->
     crypto:hmac(sha256, Key, Str).
+-endif.
+-else.
+hmac(Key, Str) ->
+    crypto:hmac(sha256, Key, Str).
+-endif.
 
 h(Str) ->
     crypto:hash(sha256, Str).