hash

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

hash

This package is used to calculate file hash.

The NewWithOs method will automatically call the os.File.Close() method by default. To prevent the call, see the following example.

package main

import (
    "fmt"
    "os"

	"github.com/3JoB/ulib/fsutil/hash"
)

func main(){
    y, err := os.Open("GMakefile.yml")
    if err != nil {
        return nil
    }
    md5, _ := hash.NewWithOs(y).DisableAutoClose().MD5()
    fmt.Println(md5)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash struct {
	File    string
	HmacKey string
	Hmac    bool
}

func NewWithPath added in v1.6.0

func NewWithPath(path string) *Hash

func (*Hash) CRC32

func (h *Hash) CRC32() (string, error)

func (*Hash) HMAC added in v1.9.0

func (h *Hash) HMAC(key string) *Hash

func (*Hash) MD5

func (h *Hash) MD5() (string, error)

func (*Hash) SHA1

func (h *Hash) SHA1() (string, error)

func (*Hash) SHA256

func (h *Hash) SHA256() (string, error)

func (*Hash) SHA512 added in v1.9.0

func (h *Hash) SHA512() (string, error)

type HashF added in v1.6.0

type HashF struct {
	Os    *os.File
	Close bool
}

func NewWithOs added in v1.6.0

func NewWithOs(o *os.File) *HashF

func (*HashF) CRC32 added in v1.6.0

func (h *HashF) CRC32() (string, error)

func (*HashF) DisableAutoClose added in v1.6.0

func (h *HashF) DisableAutoClose() *HashF

func (*HashF) MD5 added in v1.6.0

func (h *HashF) MD5() (string, error)

func (*HashF) SHA1 added in v1.6.0

func (h *HashF) SHA1() (string, error)

func (*HashF) SHA256 added in v1.6.0

func (h *HashF) SHA256() (string, error)

Jump to

Keyboard shortcuts

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