ed2k

package module
v0.0.0-...-d0cb88a Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: MIT Imports: 4 Imported by: 1

README

ED2K

This package implements the ed2k hashing algorithm. There are two different implementations that are mostly the same but differ on an edge case. Both of these are provided by this package.

The Hash

A hash is calculated by first reading the input in 9728000 byte chunks. Each chunk is then hashed with the MD4 algorithm. Once all chunks have been hashed, the list of hashes for each chunk is hashed one more time, giving the final hash.

If there is less than 9728000 bytes of data to hash, the MD4 of the data is returned without further modification.

The two implementations differ when there are is a multiple of 9728000 bytes in every chunk of the data. The Red version will add a zero-length chunk to the end and add the hash of this empty chunk to the list of hashes before computing the final hash. The Blue version does not do this.

The Sum() function uses the Blue method.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ed2k

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

func New

func New() *Ed2k

func (*Ed2k) BlockSize

func (h *Ed2k) BlockSize() int

BlockSize implements hash.BlockSize()

func (*Ed2k) Reset

func (h *Ed2k) Reset()

Reset implements hash.Reset()

func (*Ed2k) Size

func (h *Ed2k) Size() int

Size implements hash.Size()

func (*Ed2k) Sum

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

Sum implements hash.Sum()

func (*Ed2k) SumBlue

func (h *Ed2k) SumBlue() (string, error)

SumBlue implements the "Blue" hash version.

func (*Ed2k) SumRed

func (h *Ed2k) SumRed() (string, error)

SumRed implements the bugged ("Red") version of the hash. See https://wiki.anidb.net/Ed2k-hash#How_is_an_ed2k_hash_calculated_exactly? for more info.

func (*Ed2k) Write

func (h *Ed2k) Write(p []byte) (int, error)

Write implements hash.Write()

Jump to

Keyboard shortcuts

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