https://github.com/edmartt/go-password-hasher
Password hasher with random salts
https://github.com/edmartt/go-password-hasher
Last synced: 10 months ago
JSON representation
Password hasher with random salts
- Host: GitHub
- URL: https://github.com/edmartt/go-password-hasher
- Owner: Edmartt
- License: mit
- Created: 2022-03-23T07:38:16.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-11T23:31:32.000Z (over 1 year ago)
- Last Synced: 2025-03-28T14:22:16.402Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Password Hasher
This project is intended to ease the use of **bcrypt** package abstracting the developer from using arrays of bytes and all necessary stuff for hashing a string and making it as simple as just to call the need function and passing a string as argument
### What you can do:
- convert a plaintext string to hash
- checks if a plaintext string is equal to a hash
#### How to use
##### hashing strings
```
import (
"fmt"
"github.com/Edmartt/go-password-hasher/hasher"
)
func main(){
myString := "12345"
hashedString := hasher.ConvertToHash(myString)
fmt.Println(hashedString)
}
```
We'll see some output like this:
- **$2a$10$J65kHWsGVPLJq47D5aBJmeBpytRtXM5F6iN4ZId/Eum5IXw4cOMfi**
##### Checking if a hash equals to a string we pass as argument:
```
import (
"fmt"
"github.com/Edmartt/go-password-hasher/hasher"
)
func main(){
myString := "12345"
hashedString := hasher.ConvertToHash(myString)
isTheSame := hasher.CheckHash(hashedString, "12345")
fmt.Println(isTheSame)
}
```
Our output here would be:
- **true**
#### Unit Test
For running test:
```
go test -v ./tests
```
#### Coverage
Running coverage:
```
go test -v --coverprofile=coverage.out -coverpkg ./hasher ./tests
```