xhash

package
v0.25.15 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 6

README

GoKit - xhash

Hash kits for Golang development.

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/xhash"
)

Documentation

Visit the docs on GoDoc

Example

Get md5 of string
h := xhash.Md5("12345678")
fmt.Println(h.Hex())
fmt.Println(h.B64())

Get Hmac Md5 of string

h := xhash.HmacMd5("key", "12345678")
fmt.Println(h.Hex())
fmt.Println(h.B64())
Get md5 of file
h, err := xhash.FileMd5("xhash.go")
if err != nil {
    panic(err)
}
fmt.Println(h.Hex())
fmt.Println(h.B64())

License

Copyright 2012-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Author

func Author() string

Author returns package author

func License

func License() string

License returns package license

func Version

func Version() string

Version returns package version

Types

type Hashx

type Hashx struct {
	Hash hash.Hash
}

Hashx storing hash object

func FileMd5

func FileMd5(f interface{}) (h Hashx, err error)

FileMd5 returns md5 hash of file

func FileSha1

func FileSha1(f interface{}) (h Hashx, err error)

FileSha1 returns sha1 hash of file

func FileSha256

func FileSha256(f interface{}) (h Hashx, err error)

FileSha256 returns sha256 hash of file

func FileSha512

func FileSha512(f interface{}) (h Hashx, err error)

FileSha512 returns sha512 hash of file

func HmacMd5

func HmacMd5(key string, s ...interface{}) (h Hashx)

HmacMd5 returns hmac md5 hash of string with key

func HmacSha1

func HmacSha1(key string, s ...interface{}) (h Hashx)

HmacSha1 returns hmac sha1 hash of string with key

func HmacSha256

func HmacSha256(key string, s ...interface{}) (h Hashx)

HmacSha256 returns hmac sha256 hash of string with key

func HmacSha512

func HmacSha512(key string, s ...interface{}) (h Hashx)

HmacSha512 returns hmac sha512 hash of string with key

func Md5

func Md5(s ...interface{}) (h Hashx)

Md5 returns md5 hash of string

func Sha1

func Sha1(s ...interface{}) (h Hashx)

Sha1 returns sha1 hash of string

func Sha256

func Sha256(s ...interface{}) (h Hashx)

Sha256 returns sha256 hash of string

func Sha512

func Sha512(s ...interface{}) (h Hashx)

Sha512 returns sha512 hash of string

func (Hashx) Base64 added in v0.25.1

func (h Hashx) Base64() string

Base64 encoding hash sum as base64 string

func (Hashx) Bytes added in v0.25.1

func (h Hashx) Bytes() []byte

Bytes returns hash sum as bytes

func (Hashx) Hex

func (h Hashx) Hex() string

Hex encoding hash sum as hex string

Jump to

Keyboard shortcuts

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