Compare commits
No commits in common. "c216e4903904f76dc6f10449eba38d15ad7660c1" and "bd72a9b11d0e1db865e8c32156843f477027cfa2" have entirely different histories.
c216e49039
...
bd72a9b11d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
test
|
||||
.kdev4
|
||||
.vscode
|
||||
|
40
README.md
40
README.md
@ -11,28 +11,38 @@ go get github.com/GRMrGecko/go-passwd
|
||||
## Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"github.com/GRMrGecko/go-passwd"
|
||||
"github.com/GRMrGecko/go-passwd"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
result, err := passwd.CheckPassword([]byte("$y$j9T$Q3N1jZa3Cp.yNINNDt5dDgYkHU7k$9o7WJJB5F.tTEhZdz6T6LMWY/0C3JkhvmcNyUPvUBlC"), []byte("Test"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
result, err := passwd.CheckPassword([]byte("$y$j9T$Q3N1jZa3Cp.yNINNDt5dDgYkHU7k$9o7WJJB5F.tTEhZdz6T6LMWY/0C3JkhvmcNyUPvUBlC"), []byte("Test"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if result {
|
||||
log.Println("Password confirmed, saving new password.")
|
||||
if result {
|
||||
log.Println("Password confirmed, saving new password.")
|
||||
|
||||
pw := passwd.NewSHA512CryptPasswd()
|
||||
hash, err := pw.HashPassword([]byte("New Password!!!"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
log.Println("The new password hash to save is:", string(hash))
|
||||
}
|
||||
pw := passwd.NewSHA512CryptPasswd()
|
||||
hash, err := pw.HashPassword([]byte("New Password!!!"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
log.Println("The new password hash to save is:", string(hash))
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Example output:
|
||||
```
|
||||
$ ./test
|
||||
2024/09/07 18:42:35 Password confirmed, saving new password.
|
||||
2024/09/07 18:42:35 The new password hash to save is: $6$4Eu/l5e.otcRj0rJ$YAlwxJD9pZY9.Z2TjseCbkXiUIrFU2AXh9DPEm5Z1SagxP..xaQCsz7jAgfW4nmUbLh.o23pEZGvvxPCLltf11
|
||||
```
|
||||
|
||||
## Known issues
|
||||
|
Loading…
Reference in New Issue
Block a user