blake2botp

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package blake2botp provides BLAKE2b-based hash implementations for use with one-time passwords (OTP).

The package defines hash functions (blake2botp.New256, blake2botp.New384, blake2botp.New512) that wrap the BLAKE2b hash function from the golang.org/x/crypto/blake2b package. These functions return hash instances that implement the hash.Hash interface, allowing them to be used as drop-in replacements for other hash functions in OTP implementations.

Usage:

hasher := blake2botp.New512()
// Use the hasher with the OTP implementation

The package provides the following functions:

  • blake2botp.New256: Returns a new instance of the BLAKE2b hash with a 256-bit output size.
  • blake2botp.New384: Returns a new instance of the BLAKE2b hash with a 384-bit output size.
  • blake2botp.New512: Returns a new instance of the BLAKE2b hash with a 512-bit output size.

The returned hash instances implement the hash.Hash interface, so they can be used directly with OTP libraries that expect a hash function.

Note: The BLAKE2b hash functions provided by this package are secure and efficient hashing algorithms. However, it's important to ensure that the secret key used with the OTP implementation is kept secure and not disclosed to unauthorized parties. Also, note that some 2FA mobile apps might not support these hash functions, so it is recommended to build your own 2FA mobile apps for compatibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New256

func New256() hash.Hash

New256 returns a new instance of the Blake2botp hash with a 256-bit output size. The returned hash implements the hash.Hash interface.

func New384

func New384() hash.Hash

New384 returns a new instance of the Blake2botp hash with a 384-bit output size. The returned hash implements the hash.Hash interface.

func New512

func New512() hash.Hash

New512 returns a new instance of the Blake2botp hash with a 512-bit output size. The returned hash implements the hash.Hash interface.

Types

type Blake2botp

type Blake2botp struct {
	// contains filtered or unexported fields
}

Blake2botp is a struct that wraps the BLAKE2b hash function. It implements the hash.Hash interface.

func (*Blake2botp) BlockSize

func (h *Blake2botp) BlockSize() int

BlockSize returns the hash's underlying block size.

func (*Blake2botp) Reset

func (h *Blake2botp) Reset()

Reset resets the hash to its initial state.

func (*Blake2botp) Size

func (h *Blake2botp) Size() int

Size returns the number of bytes Sum will return.

func (*Blake2botp) Sum

func (h *Blake2botp) Sum(b []byte) []byte

Sum appends the current hash to b and returns the resulting slice.

func (*Blake2botp) Write

func (h *Blake2botp) Write(p []byte) (n int, err error)

Write writes the given bytes to the hash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL