Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, err := hashbag.RandomString(32, charset.LowercaseAlpha, charset.UppercaseAlpha, charset.Numeric)
	if err != nil {
		panic(err)
	}
	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)
}

About

A Go Library for generating random strings and hashing.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages