commit 94d73fbdada9d6a5f67f05f97e1ec4d0dc3bcbb9 parent 250836f69273f32bb2f71ce344cce731b0baf5c4 Author: n0tr1v <n0tr1v@protonmail.com> Date: Wed, 11 Jan 2023 10:50:14 -0800 cleanup Diffstat:
| M | pkg/database/tableChatRooms.go | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pkg/database/tableChatRooms.go b/pkg/database/tableChatRooms.go @@ -44,11 +44,15 @@ func CreateRoom(name string, passwordHash string, ownerID UserID, isListed bool) } func GetRoomPasswordHash(password string) string { - return utils.Sha512([]byte(config.RoomPasswordSalt + password)) + return utils.Sha512(getSaltedPasswordBytes(password)) } func GetRoomDecryptionKey(password string) string { - return utils.Sha256([]byte(config.RoomPasswordSalt + password))[:32] + return utils.Sha256(getSaltedPasswordBytes(password))[:32] +} + +func getSaltedPasswordBytes(password string) []byte { + return []byte(config.RoomPasswordSalt + password) } // IsOwned returns either or not a user created the room