hashbag

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 8 Imported by: 0

README

Hashbag

Your all-in-one tool for generating random hashes and strings.

Setup

go get -u github.com/inventorandy/hashbag

Examples

Generating a Random String

Generate a random string of 32 chars using lowercase, uppercase and numeric characters:

package main

import (
	"fmt"

	"github.com/inventorandy/hashbag"
	"github.com/inventorandy/hashbag/charset"
)

func main() {
	str := hashbag.RandomString(32, charset.LowercaseAlpha, charset.UppercaseAlpha, charset.Numeric)
	fmt.Println("Random String:", str)
}
Hashing a Password with a Random Salt
package main

import (
	"fmt"

	"github.com/inventorandy/hashbag"
	"github.com/inventorandy/hashbag/charset"
)

func main() {
	salt := hashbag.RandomString(32, charset.LowercaseAlpha, charset.UppercaseAlpha, charset.Numeric, charset.Special)
	password := "myPassword123"
	hashedPassword := hashbag.SHA256HashString(password, salt)

	fmt.Println("Password:", password)
	fmt.Println("Salt    :", salt)
	fmt.Println("Hashed  :", hashedPassword)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MD5HashString

func MD5HashString(s ...string) string

MD5HashString generates a MD5 hash of the given string(s). and returns the hash as a string.

func RandomString

func RandomString(length int, charset ...charset.Charset) string

RandomString generates a random string of the given length using the given charset(s). If no charset is provided, it will use the default charset (lowercase alpha, uppercase alpha, and numeric). The charset(s) can be any combination of the following: - charset.LowercaseAlpha - charset.UppercaseAlpha - charset.Numeric - charset.Special Example:

RandomString(10) // "aBcD3eFgH1"
RandomString(10, charset.LowercaseAlpha, charset.Numeric) // "a1b2c3d4e5"
RandomString(10, charset.LowercaseAlpha, charset.UppercaseAlpha) // "aBcDeFgHiJ"

func SHA256HashString

func SHA256HashString(s ...string) string

MD5HashString generates a SHA256 hash of the given string(s). and returns the hash as a string.

func SHA512HashString

func SHA512HashString(s ...string) string

SHA512HashString generates a SHA512 hash of the given string(s). and returns the hash as a string.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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