Ejemplo n.º 1
0
func (c *sha2Crypter) NeedsUpdate(stub string) bool {
	_, salt, _, rounds, err := raw.Parse(stub)
	if err != nil {
		return false // ...
	}

	return c.needsUpdate(salt, rounds)
}
Ejemplo n.º 2
0
func (c *sha2Crypter) hash(password, stub string) (oldHash, newHash, salt string, rounds int, err error) {
	isSHA512, salt, oldHash, rounds, err := raw.Parse(stub)
	if err != nil {
		return "", "", "", 0, err
	}

	if isSHA512 != c.sha512 {
		return "", "", "", 0, errInvalidStub
	}

	if c.sha512 {
		return oldHash, raw.Crypt512(password, salt, rounds), salt, rounds, nil
	}

	return oldHash, raw.Crypt256(password, salt, rounds), salt, rounds, nil
}