|
|
@@ -7,7 +7,7 @@ package auth
|
|
|
|
|
|
import (
|
|
|
"crypto/rand"
|
|
|
- "crypto/sha256"
|
|
|
+ "crypto/sha512"
|
|
|
"encoding/base64"
|
|
|
"encoding/hex"
|
|
|
"encoding/json"
|
|
|
@@ -70,7 +70,7 @@ func WsAuthCheck(conn *websocket.Conn) bool {
|
|
|
func AddToAuthMap(conn *websocket.Conn, token map[string]string, authed bool) error {
|
|
|
tokenStr := token["token"]
|
|
|
tokenId := token["id"]
|
|
|
- hashed := sha256.Sum256([]byte(tokenStr))
|
|
|
+ hashed := sha512.Sum512([]byte(tokenStr))
|
|
|
hash := hex.EncodeToString(hashed[:])
|
|
|
if authed {
|
|
|
AuthenticatedClients.Lock()
|
|
|
@@ -121,7 +121,7 @@ func CheckToken(token map[string]string, conn *websocket.Conn, r *http.Request,
|
|
|
ip, _, _ = net.SplitHostPort(r.RemoteAddr)
|
|
|
}
|
|
|
userAgent := r.Header.Get("User-Agent")
|
|
|
- hashed := sha256.Sum256([]byte(token["token"]))
|
|
|
+ hashed := sha512.Sum512([]byte(token["token"]))
|
|
|
hash := hex.EncodeToString(hashed[:])
|
|
|
// you in auth map?
|
|
|
if WsIsAuthenticated(conn, hash) {
|
|
|
@@ -269,12 +269,12 @@ func KeyfileDecrypt(encryptedText string, key string) (map[string]string, error)
|
|
|
return contents, nil
|
|
|
}
|
|
|
|
|
|
-// salted sha256
|
|
|
+// salted sha512
|
|
|
func Hasher(password string) string {
|
|
|
conf := config.Conf()
|
|
|
salt := conf.Salt
|
|
|
toHash := salt + password
|
|
|
- res := sha256.Sum256([]byte(toHash))
|
|
|
+ res := sha512.Sum512([]byte(toHash))
|
|
|
return hex.EncodeToString(res[:])
|
|
|
}
|
|
|
|