Documentation ¶
Overview ¶
Package hash implements the hash functions specified in the noise protocol.
It currently supports four hash functions: SHA256, SHA512, BLAKE2a, and BLAKE2s.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedHashes ¶
func SupportedHashes() string
SupportedHashes gives the names of all the hashs registered. If no new hashs are registered, it returns a string as "AESGCM, ChaChaPoly", orders not preserved.
Types ¶
type Hash ¶
type Hash interface { fmt.Stringer // BlockLen returns a constant specifying the size in bytes that the hash // function uses internally to divide its input for iterative processing. // This is needed to use the hash function with HMAC. BlockLen() int // New returns the hash function used. New() hash.Hash // HashLen returns a constant specifying the size in bytes of the hash // output. Must be 32 or 64. HashLen() int // Reset resets the Hash to its initial state. Reset() }
Hash defines a hash interface specified by the noise specs.
func FromString ¶
FromString uses the provided hash name, s, to query a built-in hash.
Example ¶
package main import ( "fmt" "github.com/yyforyongyu/babble/hash" ) func main() { // load hash sha256 sha256, _ := hash.FromString("SHA256") fmt.Println(sha256) // load hash sha512 sha512, _ := hash.FromString("SHA512") fmt.Println(sha512) // load hash blake2s blake2s, _ := hash.FromString("BLAKE2s") fmt.Println(blake2s) // load hash blake2b blake2b, _ := hash.FromString("BLAKE2b") fmt.Println(blake2b) }
Output:
Click to show internal directories.
Click to hide internal directories.