crypt

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

README

crypt

pipeline status coverage report Contributor Covenant

Implementation of cryptography and hashing helpers.

Install

go get -u lab.madbox.synology.me/gophers/crypt

Examples

// Since the brute-force implementations are pretty rubbish, you'll better use something else.
// The hashing wrapper on the other hand might be quite useful.

// To check wether MD4 is available (see the hashers map in hashing.go for all known algorithms)
if crypt.IsAvailable("MD4") {
  // ...
}

// Produce the OE-Encode hash value for 'admin'
// It's a special case, since the hash value can be directly interpreted as
// string, instead of hex encoding the byte array.
h := crypt.GetHasher("OE-Encode")
if _, err := h.Write([]byte("admin")); err != nil {
  // Handle write errors here
}
fmt.Println(string(h.Sum(nil)))
// Output: aaLldOCddklvMUWh

// Produce the MD5 hash value for 'admin'
h := crypt.GetHasher("MD5")
if _, err := h.Write([]byte("admin")); err != nil {
  // Handle write errors here
}
fmt.Printf("%x\n", h.Sum(nil))
// Output: 21232f297a57a5a743894a0e4a801fc3

Contributing

When contributing to this project, please note our Code of Conduct.

License

The GNU General Public License v3.0 (GPLv3) - see LICENSE for more details

Documentation

Overview

Package crypt implements cryptography and hashing helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BruteMT

func BruteMT(w int, h string, in string) (string, bool)

BruteMT bruteforces the needed input for hash in with the hash function h within length of maxLen (constant) using runeSet (var) as base in multi-threaded mode.

func BruteST

func BruteST(h hash.Hash, in string) (string, bool)

BruteST bruteforces the needed input for hash in with the hash function h within length of maxLen (constant) using runeSet (var) as base in single-threaded mode.

func GetHasher

func GetHasher(algo string) hash.Hash

GetHasher returns a hash function if the specified algorithm was found.

func GetHasherLazy added in v0.2.0

func GetHasherLazy(algo string) hash.Hash

GetHasherLazy is a wrapper to the function GetHasher being less opiniated about the input value.

func GetPrintableLazy added in v0.2.1

func GetPrintableLazy(algo string, hash []byte) string

GetPrintableLazy returns the string representation of a hash. Mostly it handles the fact that the OE-Encode implementation does not behave like the others.

func IsAvailable

func IsAvailable(algo string) bool

IsAvailable returns a boolean indicating support for specified hasher.

func IsAvailableLazy added in v0.2.0

func IsAvailableLazy(algo string) bool

IsAvailableLazy is a wrapper to the function IsAvailable being less opiniated about the input value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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