-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: JWT Signing key will use hashed Discord App Client ID to prevent…
… breaking on server reboot
- Loading branch information
1 parent
43fbe4e
commit 1b3219f
Showing
4 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package caddydiscord | ||
|
||
import ( | ||
"crypto/sha256" | ||
"crypto/sha512" | ||
"encoding/hex" | ||
) | ||
|
||
func hashString512(input string) string { | ||
hasher := sha512.New() | ||
hasher.Write([]byte(input)) | ||
return hex.EncodeToString(hasher.Sum(nil)) | ||
} | ||
|
||
func hashString256(input string, length int) string { | ||
hasher := sha256.New() | ||
hasher.Write([]byte(input)) | ||
fullHash := hex.EncodeToString(hasher.Sum(nil)) | ||
|
||
if length > len(fullHash) { | ||
length = len(fullHash) | ||
} | ||
return fullHash[:length] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters