From d8c0b0c89906edada0a30d144ebeb116388b45b1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 27 Dec 2013 21:21:08 +0100 Subject: [PATCH] Moved string util --- util.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 util.go diff --git a/util.go b/util.go new file mode 100644 index 0000000000..fc06673d2c --- /dev/null +++ b/util.go @@ -0,0 +1,23 @@ +package main + +import ( + "strconv" + "crypto/sha256" + "encoding/hex" +) + +func Uitoa(i uint32) string { + return strconv.FormatUint(uint64(i), 10) +} + +func Sha256Hex(data []byte) string { + hash := sha256.Sum256(data) + + return hex.EncodeToString(hash[:]) +} + +func Sha256Bin(data []byte) []byte { + hash := sha256.Sum256(data) + + return hash[:] +}