trakt: strip non alphanumeric characters from imdb id

This commit is contained in:
James Bayliss
2021-02-15 19:17:32 +00:00
parent 95cf1fe961
commit aadc5ece4f
4 changed files with 42 additions and 12 deletions

14
util/hash.go Normal file
View File

@@ -0,0 +1,14 @@
package util
import (
"crypto/sha256"
"fmt"
)
func AsSHA256(o interface{}) string {
// credits: https://blog.8bitzen.com/posts/22-08-2019-how-to-hash-a-struct-in-go
h := sha256.New()
h.Write([]byte(fmt.Sprintf("%v", o)))
return fmt.Sprintf("%x", h.Sum(nil))
}