Current section
Files
Jump to
Current section
Files
src/munch_native_ffi.erl
-module(munch_native_ffi).
-export([init/1]).
init(Algorithm) ->
try
{ok, crypto:hash_init(algorithm(Algorithm))}
catch
_:_ ->
{error, nil}
end.
algorithm(<<"md5">>) -> md5;
algorithm(<<"sha1">>) -> sha;
algorithm(<<"sha224">>) -> sha224;
algorithm(<<"sha256">>) -> sha256;
algorithm(<<"sha384">>) -> sha384;
algorithm(<<"sha512">>) -> sha512.