md4

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sum

func Sum(data []byte) [16]byte

Sum returns the MD4 checksum of the given data.

Parameters:

  • data: A byte slice containing the data to be hashed.

Returns:

  • A 16-byte array containing the MD4 checksum of the input data.

The function creates a new MD4 hash object, writes the input data to it, and then computes the final hash value. The resulting 16-byte checksum is returned as an array.

Types

type MD4

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

MD4 is a struct that implements the MD4 hash algorithm.

Fields: - state: An array of four 32-bit unsigned integers that represent the internal state of the MD4 hash. - count: A uint64 that represents the number of bits processed so far. - buffer: An array of 64 bytes that is used to store the data to be hashed.

func New

func New() *MD4

func (*MD4) HexSum

func (md4 *MD4) HexSum() string

HexSum returns the MD4 checksum of the data as a hexadecimal string.

Returns:

  • A string containing the MD4 checksum of the input data in hexadecimal format.

The function computes the MD4 checksum of the data and encodes it as a hexadecimal string. This is useful for representing the hash value in a human-readable format.

func (*MD4) Sum

func (md4 *MD4) Sum() [16]byte

Sum returns the MD4 checksum of the data.

Parameters:

  • data: A byte slice containing the data to be hashed.

Returns:

  • A 16-byte array containing the MD4 checksum of the input data.

The function creates a new MD4 hash object, writes the input data to it, and then computes the final hash value. The resulting 16-byte checksum is returned as an array.

func (*MD4) Write

func (md4 *MD4) Write(p []byte) (n int, err error)

Write adds more data to the running MD4 hash. It can be called multiple times to add more data. The MD4 hash is computed incrementally as data is written.

Parameters:

  • p: A byte slice containing the data to be added to the hash.

Returns:

  • n: The number of bytes written from p.
  • err: An error value, which is always nil in this implementation.

The function updates the internal state of the MD4 object with the new data. It processes the data in chunks of 64 bytes (the MD4 block size). If there is any remaining data that is less than a full chunk, it is buffered for the next call to Write or for the final hash computation.

Jump to

Keyboard shortcuts

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