class Sodium::Digest::Blake2b

Overview

Hash data using Blake2b.

Compatible with the Crystal OpenSSL::Digest interface.

Usage:

digest = Blake2b.new
digest.update data
digest.update data
digest.hexfinal => String

Included Modules

Defined in:

sodium/digest/blake2b.cr

Constant Summary

KEY_SIZE = LibSodium.crypto_generichash_blake2b_keybytes.to_i

32

KEY_SIZE_MAX = LibSodium.crypto_generichash_blake2b_keybytes_max.to_i

64

KEY_SIZE_MIN = LibSodium.crypto_generichash_blake2b_keybytes_min.to_i

16

Log = ::Log.for(self)
OUT_SIZE = LibSodium.crypto_generichash_blake2b_bytes.to_i32

32

OUT_SIZE_MAX = LibSodium.crypto_generichash_blake2b_bytes_max.to_i32

64

OUT_SIZE_MIN = LibSodium.crypto_generichash_blake2b_bytes_min.to_i32

16

PERSONAL_SIZE = LibSodium.crypto_generichash_blake2b_personalbytes.to_i

16

SALT_SIZE = LibSodium.crypto_generichash_blake2b_saltbytes.to_i

16

Constructors

Instance Method Summary

Instance methods inherited from module Sodium::Wipe

close close, finalize finalize

Constructor Detail

def self.new(digest_size : Int32 = OUT_SIZE, key : Bytes? | SecureBuffer? = nil, salt : Bytes? = nil, personal : Bytes? = nil) #

Create a new Blake2b Digest.

digest_size is selectable. Use 32 for Blake2b256 (libsodium default), 64 for Blake2b512 or any value between OUT_SIZE_MIN and OUT_SIZE_MAX. Many libsodium bindings only support [256] or [256 and 512] bit output.

key, salt, and personal are all optional. Many other libsodium bindings don't support them. Check the other implementation(s) you need to interoperate with before using.


[View source]

Instance Method Detail

def clone #

[View source]
def digest_size : Int32 #
Description copied from class Digest

Returns the digest output size in bytes.


[View source]
def final_impl(dst : Bytes) : Nil #
Description copied from class Digest

Stores the output digest of #digest_size bytes in dst.


[View source]
def hexfinal(dst : Bytes) : Nil #

[View source]
def hexfinal : String #

[View source]
def key_size : Int32 #

[View source]
def reset_impl : Nil #
Description copied from class Digest

Resets the object to it's initial state.


[View source]
def update_impl(data : Bytes) : Nil #
Description copied from class Digest

Hashes data incrementally.


[View source]