go: discord/modules: Do better hashing while obfuscating

master
Luther Wen Xu 2019-10-19 23:01:18 +07:00
parent 0bec62f96c
commit b6685d22bb
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 5 additions and 4 deletions

@ -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 = "<cannot calculate hash>"
}