# README
shasum - secure hash algorithm utilities
A collection of utilities for working with secure hashes.
Installation
> go get github.com/go-corelibs/shasum@latest
Examples
Hash, Sum, BriefSum
func main() {
shasum, err := shasum.Hash([]byte{}, shasum.Sha256Type)
// err == nil
// shasum == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
shasum, err = shasum.Sum([]byte{})
// err == nil
// shasum == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
shasum, err = shasum.BriefSum([]byte{})
// err == nil
// shasum == "e3b0c44298"
}
Go-CoreLibs
Go-CoreLibs is a repository of shared code between the Go-Curses and Go-Enjin projects.
License
Copyright 2024 The Go-CoreLibs Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Functions
BriefFile is a wrapper around File which returns a BriefLength `shasum`.
BriefSum is a wrapper around Sum which returns a BriefLength `shasum`.
File is a convenience wrapper around HashFile using the DefaultType.
Hash calculates the shasum of the given `data` and returns the hexadecimal encoded value
BriefType is an alias of Sha256Type and if an unknown HashType is given, Sha256Type is used.
HashFile is a convenience wrapper around reading the `file` data and returning the result of a call to Hash.
MustBriefFile is a wrapper around File which returns a BriefLength `shasum`.
MustBriefSum is a wrapper around BriefSum which panics with any error.
MustFile is a convenience wrapper around MustHashFile using the DefaultType.
MustHash is a convenience wrapper around Hash which panics with any error.
MustHashFile is a convenience wrapper around HashFile which panics with any error.
MustSum is a wrapper around Sum which panics with any error.
MustSum224 is a wrapper around Sum224 which panics with any error.
MustSum256 is a wrapper around Sum256 which panics with any error.
MustSum384 is a wrapper around Sum384 which panics with any error.
MustSum512 is a wrapper around Sum512 which panics with any error.
Sha1Bytes is a convenience wrapper around sha1.Sum
Note: do not use SHA-1 for securing data.
Sha1Sum is a convenience wrapper around Sha1Bytes, returning the `shasum` as a hexadecimal string instead of a byte array
Note: do not use SHA-1 for securing data.
Sum is a wrapper around Hash using the DefaultType.
Sum224 uses SHA-224 to hash the given `data` and return the result as a hexadecimal encoded string of Sha224Length.
Sum256 uses SHA-256 to hash the given `data` and return the result as a hexadecimal encoded string of Sha256Length.
Sum384 uses SHA-384 to hash the given `data` and return the result as a hexadecimal encoded string of Sha384Length.
Sum512 uses SHA-512 to hash the given `data` and return the result as a hexadecimal encoded string of Sha512Length.
Valid checks if the `hash` given is a valid HashLength string that passes a call to Validate.
Validate returns true if the given `hash` is exactly the HashLength required and contains only the digits 0-9 and the lower-case letters a-f.
Verify compares the given `hash` matches the exact Sum result derived from the given `data`.
VerifyFile uses Verify to validate the given file's integrity.
# Constants
BriefLength is accepted as a short-form Sha256Length.
BriefType is an alias for Sha256Type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
# Interfaces
HashInputTypes is the generic constraint for byte slice and string things.
# Type aliases
HashLength is the length of a hexadecimal encoded string produced from one of the secure hashing functions.
HashType is used to specify the DefaultType used by Sum and File.