md5x

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 5 Imported by: 6

Documentation

Overview

Example (File)
package main

import (
	"fmt"
	"os"

	"github.com/recallsong/go-utils/encoding/md5x"
)

func main() {
	file, err := os.Open("md5x.go")
	if err != nil {
		fmt.Println("error:", err)
		return
	}
	val, err := md5x.SumFile(file)
	fmt.Println(val.String(), err)
}
Output:

25d81829d5e7219164dc00a297fc579b <nil>
Example (FileByPath)
package main

import (
	"fmt"

	"github.com/recallsong/go-utils/encoding/md5x"
)

func main() {
	val, err := md5x.SumFileByPath("md5x.go")
	fmt.Println(val.String(), err)
}
Output:

25d81829d5e7219164dc00a297fc579b <nil>
Example (Short)
package main

import (
	"fmt"

	"github.com/recallsong/go-utils/encoding/md5x"
)

func main() {
	val, err := md5x.SumFileByPath("md5x.go")
	fmt.Println(val.String16(), err)
}
Output:

081a33d327980264 <nil>
Example (Sum)
package main

import (
	"fmt"

	"github.com/recallsong/go-utils/encoding/md5x"
)

func main() {
	str := md5x.Sum([]byte("123")).String()
	fmt.Println(str)
}
Output:

202cb962ac59075b964b07152d234b70
Example (SumString)
package main

import (
	"fmt"

	"github.com/recallsong/go-utils/encoding/md5x"
)

func main() {
	str := md5x.SumString("123").String()
	fmt.Println(str)
}
Output:

202cb962ac59075b964b07152d234b70

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result []byte

Result md5的结果

func Sum

func Sum(data []byte) Result

Sum 计算[]byte的md5值

func SumFile

func SumFile(file *os.File) (Result, error)

SumFile 计算文件的md5值

func SumFileByPath

func SumFileByPath(filePath string) (Result, error)

SumFileByPath 计算文件的md5值

func SumString

func SumString(data string) Result

SumString 计算string的md5值

func (Result) Bytes

func (r Result) Bytes() []byte

Bytes 获取md5的[]byte类型的结果

func (Result) String

func (r Result) String() string

String 获取md5的string类型的结果

func (Result) String16

func (r Result) String16() string

String16 获取md5的16位的string类型结果

func (Result) UpperString

func (r Result) UpperString() string

UpperString 获取md5的大写的string类型的结果

func (Result) UpperString16

func (r Result) UpperString16() string

UpperString16 获取md5的16位的大写的string类型结果

Jump to

Keyboard shortcuts

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