streamwatcher/util.go

20 lines
421 B
Go
Executable file

package main
import (
"crypto/sha256"
"encoding/base64"
"os"
)
// URLToBase64 returns the base64 encoding of the URL parameter
func URLToBase64(URL string) string {
h := sha256.New()
h.Write([]byte(URL))
return base64.URLEncoding.EncodeToString(h.Sum(nil))
}
// FileExists returns true if path exists
func FileExists(path string) bool {
_, err := os.Stat(path)
return !os.IsNotExist(err)
}