Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jasei/hashutil-go

Hashutil is collection of common hash (crypto) types. It also contains some helper functions for hash manipulation.
https://github.com/jasei/hashutil-go

go golang hactoberfest hash hashing md5 sha256

Last synced: 20 days ago
JSON representation

Hashutil is collection of common hash (crypto) types. It also contains some helper functions for hash manipulation.

Awesome Lists containing this project

README

        

# hashutil

[![Release](https://img.shields.io/github/release/avast/hashutil-go.svg?style=flat-square)](https://github.com/avast/hashutil-go/releases/latest)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Travis](https://img.shields.io/travis/avast/hashutil-go.svg?style=flat-square)](https://travis-ci.org/avast/hashutil-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/avast/hashutil-go?style=flat-square)](https://goreportcard.com/report/github.com/avast/hashutil-go)
[![GoDoc](https://godoc.org/github.com/avast/hashutil-go?status.svg&style=flat-square)](http://godoc.org/github.com/avast/hashutil-go)
[![codecov.io](https://codecov.io/github/avast/hashutil-go/coverage.svg?branch=master)](https://codecov.io/github/avast/hashutil-go?branch=master)
[![Sourcegraph](https://sourcegraph.com/github.com/avast/hashutil-go/-/badge.svg)](https://sourcegraph.com/github.com/avast/hashutil-go?badge)
[![GolangCI](https://golangci.com/badges/github.com/golangci/golangci-lint.svg)](https://golangci.com)

Package hashutil is collection of common hash (crypto) types. It also contains
some helper functions for hash manipulation.

Supports Md5, Sha1, Sha256, Sha384, Sha512.

For support other crypto functions please do PR or issue.

### SYNOPSIS

import (
"github.com/avast/hashutil-go",
"crypto/md5"
)

hash, _ := hashutil.StringToMd5("d41d8cd98f00b204e9800998ecf8427e")
otherHash, _ := hashutil.BytesToMd5(md5.New().Sum(nil))
// or
// otherhash := hashutil.EmptyMd5()

if hash.Equal(otherHash) {
// do something
}

Code generated by github.com/jasei/hashutil/generator DO NOT EDIT

Code generated by github.com/jasei/hashutil/generator DO NOT EDIT

Code generated by github.com/jasei/hashutil/generator DO NOT EDIT

Code generated by github.com/jasei/hashutil/generator DO NOT EDIT

Code generated by github.com/jasei/hashutil/generator DO NOT EDIT

## Usage

#### type Md5

```go
type Md5 []byte
```

Md5 type represents Md5 checksum

#### func BytesToMd5

```go
func BytesToMd5(bytes []byte) (Md5, error)
```
BytesToMd5 return a new Md5 checksum from bytes (binary) representation

#### func EmptyMd5

```go
func EmptyMd5() Md5
```
EmptyMd5 return Md5 of empty file

#### func HashToMd5

```go
func HashToMd5(h hash.Hash) (Md5, error)
```
HashToMd5 return a new Md5 checksum from hash.Hash representation HashToMd5
convert hashutil.Hash to Md5

#### func StringToMd5

```go
func StringToMd5(hexString string) (Md5, error)
```
StringToMd5 return a new Md5 checksum from string (hex) representation

#### func (Md5) Equal

```go
func (h Md5) Equal(o Md5) bool
```
Equal return true if is Md5s equal

#### func (Md5) IsEmpty

```go
func (h Md5) IsEmpty() bool
```
IsEmpty return true if is Md5 'empty hash'

#### func (Md5) String

```go
func (h Md5) String() string
```
String return (hex) string representation of Md5

#### func (Md5) ToBase64

```go
func (h Md5) ToBase64() string
```
ToBase64 return base64 representation of Md5

#### func (Md5) ToBytes

```go
func (h Md5) ToBytes() []byte
```
ToBytes return []byte of hashutil.Md5

#### func (Md5) UpperString

```go
func (h Md5) UpperString() string
```
UpperString return (hex) string representation in upper case of Md5

#### type Sha1

```go
type Sha1 []byte
```

Sha1 type represents Sha1 checksum

#### func BytesToSha1

```go
func BytesToSha1(bytes []byte) (Sha1, error)
```
BytesToSha1 return a new Sha1 checksum from bytes (binary) representation

#### func EmptySha1

```go
func EmptySha1() Sha1
```
EmptySha1 return Sha1 of empty file

#### func HashToSha1

```go
func HashToSha1(h hash.Hash) (Sha1, error)
```
HashToSha1 return a new Sha1 checksum from hash.Hash representation HashToSha1
convert hashutil.Hash to Sha1

#### func StringToSha1

```go
func StringToSha1(hexString string) (Sha1, error)
```
StringToSha1 return a new Sha1 checksum from string (hex) representation

#### func (Sha1) Equal

```go
func (h Sha1) Equal(o Sha1) bool
```
Equal return true if is Sha1s equal

#### func (Sha1) IsEmpty

```go
func (h Sha1) IsEmpty() bool
```
IsEmpty return true if is Sha1 'empty hash'

#### func (Sha1) String

```go
func (h Sha1) String() string
```
String return (hex) string representation of Sha1

#### func (Sha1) ToBase64

```go
func (h Sha1) ToBase64() string
```
ToBase64 return base64 representation of Sha1

#### func (Sha1) ToBytes

```go
func (h Sha1) ToBytes() []byte
```
ToBytes return []byte of hashutil.Sha1

#### func (Sha1) UpperString

```go
func (h Sha1) UpperString() string
```
UpperString return (hex) string representation in upper case of Sha1

#### type Sha256

```go
type Sha256 []byte
```

Sha256 type represents Sha256 checksum

#### func BytesToSha256

```go
func BytesToSha256(bytes []byte) (Sha256, error)
```
BytesToSha256 return a new Sha256 checksum from bytes (binary) representation

#### func EmptySha256

```go
func EmptySha256() Sha256
```
EmptySha256 return Sha256 of empty file

#### func HashToSha256

```go
func HashToSha256(h hash.Hash) (Sha256, error)
```
HashToSha256 return a new Sha256 checksum from hash.Hash representation
HashToSha256 convert hashutil.Hash to Sha256

#### func StringToSha256

```go
func StringToSha256(hexString string) (Sha256, error)
```
StringToSha256 return a new Sha256 checksum from string (hex) representation

#### func (Sha256) Equal

```go
func (h Sha256) Equal(o Sha256) bool
```
Equal return true if is Sha256s equal

#### func (Sha256) IsEmpty

```go
func (h Sha256) IsEmpty() bool
```
IsEmpty return true if is Sha256 'empty hash'

#### func (Sha256) String

```go
func (h Sha256) String() string
```
String return (hex) string representation of Sha256

#### func (Sha256) ToBase64

```go
func (h Sha256) ToBase64() string
```
ToBase64 return base64 representation of Sha256

#### func (Sha256) ToBytes

```go
func (h Sha256) ToBytes() []byte
```
ToBytes return []byte of hashutil.Sha256

#### func (Sha256) UpperString

```go
func (h Sha256) UpperString() string
```
UpperString return (hex) string representation in upper case of Sha256

#### type Sha384

```go
type Sha384 []byte
```

Sha384 type represents Sha384 checksum

#### func BytesToSha384

```go
func BytesToSha384(bytes []byte) (Sha384, error)
```
BytesToSha384 return a new Sha384 checksum from bytes (binary) representation

#### func EmptySha384

```go
func EmptySha384() Sha384
```
EmptySha384 return Sha384 of empty file

#### func HashToSha384

```go
func HashToSha384(h hash.Hash) (Sha384, error)
```
HashToSha384 return a new Sha384 checksum from hash.Hash representation
HashToSha384 convert hashutil.Hash to Sha384

#### func StringToSha384

```go
func StringToSha384(hexString string) (Sha384, error)
```
StringToSha384 return a new Sha384 checksum from string (hex) representation

#### func (Sha384) Equal

```go
func (h Sha384) Equal(o Sha384) bool
```
Equal return true if is Sha384s equal

#### func (Sha384) IsEmpty

```go
func (h Sha384) IsEmpty() bool
```
IsEmpty return true if is Sha384 'empty hash'

#### func (Sha384) String

```go
func (h Sha384) String() string
```
String return (hex) string representation of Sha384

#### func (Sha384) ToBase64

```go
func (h Sha384) ToBase64() string
```
ToBase64 return base64 representation of Sha384

#### func (Sha384) ToBytes

```go
func (h Sha384) ToBytes() []byte
```
ToBytes return []byte of hashutil.Sha384

#### func (Sha384) UpperString

```go
func (h Sha384) UpperString() string
```
UpperString return (hex) string representation in upper case of Sha384

#### type Sha512

```go
type Sha512 []byte
```

Sha512 type represents Sha512 checksum

#### func BytesToSha512

```go
func BytesToSha512(bytes []byte) (Sha512, error)
```
BytesToSha512 return a new Sha512 checksum from bytes (binary) representation

#### func EmptySha512

```go
func EmptySha512() Sha512
```
EmptySha512 return Sha512 of empty file

#### func HashToSha512

```go
func HashToSha512(h hash.Hash) (Sha512, error)
```
HashToSha512 return a new Sha512 checksum from hash.Hash representation
HashToSha512 convert hashutil.Hash to Sha512

#### func StringToSha512

```go
func StringToSha512(hexString string) (Sha512, error)
```
StringToSha512 return a new Sha512 checksum from string (hex) representation

#### func (Sha512) Equal

```go
func (h Sha512) Equal(o Sha512) bool
```
Equal return true if is Sha512s equal

#### func (Sha512) IsEmpty

```go
func (h Sha512) IsEmpty() bool
```
IsEmpty return true if is Sha512 'empty hash'

#### func (Sha512) String

```go
func (h Sha512) String() string
```
String return (hex) string representation of Sha512

#### func (Sha512) ToBase64

```go
func (h Sha512) ToBase64() string
```
ToBase64 return base64 representation of Sha512

#### func (Sha512) ToBytes

```go
func (h Sha512) ToBytes() []byte
```
ToBytes return []byte of hashutil.Sha512

#### func (Sha512) UpperString

```go
func (h Sha512) UpperString() string
```
UpperString return (hex) string representation in upper case of Sha512

## Contributing

Contributions are very much welcome.

### Makefile

Makefile provides several handy rules, like README.md `generator` , `setup` for prepare build/dev environment, `test`, `cover`, etc...

Try `make help` for more information.

### Before pull request

please try:
* run tests (`make test`)
* run linter (`make lint`)
* if your IDE don't automaticaly do `go fmt`, run `go fmt` (`make fmt`)

### README

README.md are generate from template [.godocdown.tmpl](.godocdown.tmpl) and code documentation via [godocdown](https://github.com/robertkrimen/godocdown).

Never edit README.md direct, because your change will be lost.