Packages

BLAKE2 hash functions - Gleam bindings for the Elixir `blake2` package.

Current section

Files

Jump to
gblake2 src gblake2.erl
Raw

src/gblake2.erl

-module(gblake2).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/gblake2.gleam").
-export([hash2b/2, hash2b_secret/3, hash2s/2, hash2s_secret/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/gblake2.gleam", 11).
?DOC(
" Blake2b hashing\n"
"\n"
" Note that the `output_size` is in bytes, not bits\n"
"\n"
" - 64 => Blake2b-512\n"
" - 48 => Blake2b-384\n"
" - 32 => Blake2b-256\n"
"\n"
" Per the specification, any `output_size` between 1 and 64 bytes is supported.\n"
).
-spec hash2b(bitstring(), integer()) -> bitstring().
hash2b(M, Output_size) ->
'Elixir.Blake2':hash2b(M, Output_size).
-file("src/gblake2.gleam", 23).
?DOC(
" Blake2b hashing\n"
"\n"
" Note that the `output_size` is in bytes, not bits\n"
"\n"
" - 64 => Blake2b-512\n"
" - 48 => Blake2b-384\n"
" - 32 => Blake2b-256\n"
"\n"
" Per the specification, any `output_size` between 1 and 64 bytes is supported.\n"
).
-spec hash2b_secret(bitstring(), integer(), bitstring()) -> bitstring().
hash2b_secret(M, Output_size, Secret_key) ->
'Elixir.Blake2':hash2b(M, Output_size, Secret_key).
-file("src/gblake2.gleam", 39).
?DOC(
" Blake2s hashing\n"
"\n"
" Note that the output_size is in bytes, not bits\n"
"\n"
" - 32 => Blake2s-256\n"
" - 24 => Blake2b-192\n"
" - 16 => Blake2b-128\n"
"\n"
" Per the specification, any output_size between 1 and 32 bytes is supported.\n"
).
-spec hash2s(bitstring(), integer()) -> bitstring().
hash2s(M, Output_size) ->
'Elixir.Blake2':hash2s(M, Output_size).
-file("src/gblake2.gleam", 51).
?DOC(
" Blake2s hashing\n"
"\n"
" Note that the output_size is in bytes, not bits\n"
"\n"
" - 32 => Blake2s-256\n"
" - 24 => Blake2b-192\n"
" - 16 => Blake2b-128\n"
"\n"
" Per the specification, any output_size between 1 and 32 bytes is supported.\n"
).
-spec hash2s_secret(bitstring(), integer(), bitstring()) -> bitstring().
hash2s_secret(M, Output_size, Secret_key) ->
'Elixir.Blake2':hash2s(M, Output_size, Secret_key).