mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 21:57:14 -04:00
Hash App token (#6724)
This commit is contained in:
parent
1fa9662946
commit
46373e7657
16 changed files with 239 additions and 44 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"crypto/sha1"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
@ -54,6 +55,13 @@ func EncodeSha1(str string) string {
|
|||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
// EncodeSha256 string to sha1 hex value.
|
||||
func EncodeSha256(str string) string {
|
||||
h := sha256.New()
|
||||
h.Write([]byte(str))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
// ShortSha is basically just truncating.
|
||||
// It is DEPRECATED and will be removed in the future.
|
||||
func ShortSha(sha1 string) string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue