With the crypt()
function in a C program, I got the following hash for the password "toto":
$6$QSX8hjVa$Oj9IAu50jSsAAm62MOo63Ea4p1o8DC0zcR6I8N5f4jRgE0Bv0WRFEJwO4hGxAAMyOF2ON5Dwze2InWV9nDWVm1
However, when using the following code, I have an error:
package main
import (
"fmt"
"os"
"golang.org/x/crypto/bcrypt"
)
func main() {
hashToCrack := "$6$QSX8hjVa$Oj9IAu50jSsAAm62MOo63Ea4p1o8DC0zcR6I8N5f4jRgE0Bv0WRFEJwO4hGxAAMyOF2ON5Dwze2InWV9nDWVm1"
fmt.Println(bcrypt.CompareHashAndPassword([]byte(hashToCrack), []byte("toto")))
}
$ go run main.go
crypto/bcrypt: bcrypt algorithm version '6' requested is newer than current version '2'
Using bcrypt with the $6$ ID is necessary in my project (more details in comments), but the bcrypt
package doesn't seems to support this version. Is there an alternative way or do I misuse the package ?