repositorypackage
0.0.3
Repository: https://github.com/inventorandy/hashbag.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# 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)
}