mirror of
https://github.com/versia-pub/versia-go.git
synced 2025-12-06 06:28:18 +01:00
23 lines
326 B
Go
23 lines
326 B
Go
|
|
package helpers
|
||
|
|
|
||
|
|
import (
|
||
|
|
"crypto/sha256"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func HashSHA256(data []byte) []byte {
|
||
|
|
h := sha256.New()
|
||
|
|
|
||
|
|
h.Write(data)
|
||
|
|
|
||
|
|
return h.Sum(nil)
|
||
|
|
}
|
||
|
|
|
||
|
|
func ISO8601(t time.Time) string {
|
||
|
|
return t.Format("2006-01-02T15:04:05Z")
|
||
|
|
}
|
||
|
|
|
||
|
|
func ParseISO8601(s string) (time.Time, error) {
|
||
|
|
return time.Parse("2006-01-02T15:04:05Z", s)
|
||
|
|
}
|