From b6685d22bb01cf5336c986172481e89d5328f37f Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Sat, 19 Oct 2019 23:01:18 +0800 Subject: [PATCH] go: discord/modules: Do better hashing while obfuscating --- GoBot/discord/modules/admin.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/GoBot/discord/modules/admin.go b/GoBot/discord/modules/admin.go index a261435..4ca690a 100644 --- a/GoBot/discord/modules/admin.go +++ b/GoBot/discord/modules/admin.go @@ -63,7 +63,7 @@ var viewTrustLevel = adminOnly(func(s *discordgo.Session, m *discordgo.MessageCr ).Send(s, m.ChannelID) return } - value, err := backend.GetTrust(s, command[1]) + value, err := backend.GetTrust(s, user.User.ID) if err != nil { message.AuditError(s, m.ChannelID, err) return @@ -97,6 +97,8 @@ var viewTrustLevel = adminOnly(func(s *discordgo.Session, m *discordgo.MessageCr rand.Read(salt) //Generate message + hash := sha512.New() + hash.Write(salt) msg := message.NewEmbed().SetColour(config.VTLColour).SetTitle(config.VTLGlobalTitle) for _, v := range members { value, err := backend.GetTrust(s, v.User.ID) @@ -111,9 +113,8 @@ var viewTrustLevel = adminOnly(func(s *discordgo.Session, m *discordgo.MessageCr if len(command) > 1 { username = v.User.Username + "#" + v.User.Discriminator } else { - saltedUsername := []byte(v.User.Username + "#" + v.User.Discriminator) - saltedUsername = append(saltedUsername, salt...) - username = hex.EncodeToString(sha512.New().Sum(saltedUsername))[:64] + toSalt := []byte(v.User.Username + "#" + v.User.Discriminator) + username = hex.EncodeToString(hash.Sum(toSalt))[:64] if username == "" { username = "" }