logic

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Copyright © 2026 Alessandro Riva

Licensed under the MIT License. See the LICENSE file for details.

Licensed under the MIT License. See the LICENSE file for details.

Licensed under the MIT License. See the LICENSE file for details.

Index

Constants

This section is empty.

Variables

View Source
var HashAlgorithms = []HashAlgorithm{
	{Name: "MD5", New: md5.New, Deprecated: true},
	{Name: "SHA1", New: sha1.New, Deprecated: true},
	{Name: "SHA256", New: sha256.New},
	{Name: "BLAKE3", New: func() hash.Hash { return blake3.New(32, nil) }},
}

HashAlgorithms lists the algorithms computed by HashFile, in output order. Register a new algorithm by appending to this slice.

Functions

func Base64Decode

func Base64Decode(input string) (string, error)

func Base64Encode

func Base64Encode(input string) string

func Defang

func Defang(input string) string

func DefangEmail

func DefangEmail(email string) string

func DefangURL

func DefangURL(url string) string

func Fang

func Fang(input string) string

Fang reverses the defanged URLs or email addresses.

func URLDecode

func URLDecode(input string) (string, error)

func URLEncode

func URLEncode(input string) string

Types

type HashAlgorithm

type HashAlgorithm struct {
	Name       string
	New        func() hash.Hash
	Deprecated bool // set for broken algorithms (MD5, SHA1) — off by default at the CLI
}

type HashResult

type HashResult struct {
	Name string
	Hex  string
}

func HashFile

func HashFile(path string) ([]HashResult, error)

HashFile opens path and hashes it with every registered algorithm.

func HashFileWith

func HashFileWith(path string, algos []HashAlgorithm) ([]HashResult, error)

HashFileWith opens path and hashes it with the given algorithms only.

func HashReader

func HashReader(r io.Reader) ([]HashResult, error)

HashReader computes the hex digest of every registered algorithm for the contents of r.

func HashReaderWith

func HashReaderWith(r io.Reader, algos []HashAlgorithm) ([]HashResult, error)

HashReaderWith computes the hex digest of each given algorithm for r. Each algorithm runs in its own goroutine so large inputs are hashed in parallel across CPU cores.

Jump to

Keyboard shortcuts

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