bettermd5

package
v0.0.0-...-fe22438 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2015 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package bettermd5 implements the MD5 hash algorithm as defined in RFC 1321.

Index

Examples

Constants

View Source
const BlockSize = 64

The blocksize of MD5 in bytes.

View Source
const Size = 16

The size of an MD5 checksum in bytes.

Variables

This section is empty.

Functions

func Sum

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

Sum returns the MD5 checksum of the data.

Example
package main

import (
	"fmt"
	"github.com/koofr/go-cryptoutils/bettermd5"
)

func main() {
	data := []byte("These pretzels are making me thirsty.")
	fmt.Printf("%x", bettermd5.Sum(data))
}
Output:

b0804ec967f48520697662a204f5fe72

Types

type BetterDigest

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

BetterDigest represents the partial evaluation of a checksum.

func New

func New() *BetterDigest

New returns a new hash.Hash computing the MD5 checksum.

Example
package main

import (
	"fmt"
	"github.com/koofr/go-cryptoutils/bettermd5"
	"io"
)

func main() {
	h := bettermd5.New()
	io.WriteString(h, "The fog is getting thicker!")
	io.WriteString(h, "And Leon's getting laaarger!")
	fmt.Printf("%x", h.Sum(nil))
}
Output:

e2c569be17396eca2a2e3c11578123ed

func NewFromState

func NewFromState(state []byte) *BetterDigest

New returns a new hash.Hash computing the MD5 checksum from existing state

Example
package main

import (
	"fmt"
	"github.com/koofr/go-cryptoutils/bettermd5"
	"io"
)

func main() {
	h := bettermd5.New()
	io.WriteString(h, "The fog is getting thicker!")
	h.Sum(nil)
	h1 := bettermd5.NewFromState(h.GetState())
	io.WriteString(h1, "And Leon's getting laaarger!")
	fmt.Printf("%x", h1.Sum(nil))
}
Output:

e2c569be17396eca2a2e3c11578123ed

func (*BetterDigest) BlockSize

func (d *BetterDigest) BlockSize() int

func (*BetterDigest) GetState

func (d *BetterDigest) GetState() []byte

func (*BetterDigest) Reset

func (d *BetterDigest) Reset()

func (*BetterDigest) SetState

func (d *BetterDigest) SetState(state []byte) error

func (*BetterDigest) Size

func (d *BetterDigest) Size() int

func (*BetterDigest) Sum

func (d0 *BetterDigest) Sum(in []byte) []byte

func (*BetterDigest) Write

func (d *BetterDigest) Write(p []byte) (nn int, err error)

Jump to

Keyboard shortcuts

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