Able to check submission

This commit is contained in:
nemunaire 2016-01-15 12:57:35 +01:00
parent a9f35d224b
commit e3f7cce80a
4 changed files with 51 additions and 3 deletions

View file

@ -34,8 +34,12 @@ func (e Exercice) GetKeys() ([]Key, error) {
}
}
func getHashedKey(raw_value string) [64]byte {
return sha512.Sum512([]byte(raw_value))
}
func (e Exercice) AddRawKey(name string, raw_value string) (Key, error) {
return e.AddKey(name, sha512.Sum512([]byte(raw_value)))
return e.AddKey(name, getHashedKey(raw_value))
}
func (e Exercice) AddKey(name string, value [64]byte) (Key, error) {
@ -67,3 +71,7 @@ func (k Key) Delete() (int64, error) {
return nb, err
}
}
func (k Key) Check(val string) bool {
return k.Value == getHashedKey(val)
}