aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
diff options
context:
space:
mode:
authorobscuren <obscuren@obscura.com>2013-12-28 04:21:08 +0800
committerobscuren <obscuren@obscura.com>2013-12-28 04:21:08 +0800
commitd8c0b0c89906edada0a30d144ebeb116388b45b1 (patch)
tree6bd57b13d75cdc3d36ec2f5b6eeee929ec54886f /util.go
parentd5d2efbaf3c3a84f0084058eacd535d077c363e1 (diff)
downloadgo-tangerine-d8c0b0c89906edada0a30d144ebeb116388b45b1.tar.gz
go-tangerine-d8c0b0c89906edada0a30d144ebeb116388b45b1.tar.zst
go-tangerine-d8c0b0c89906edada0a30d144ebeb116388b45b1.zip
Moved string util
Diffstat (limited to 'util.go')
-rw-r--r--util.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 000000000..fc06673d2
--- /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[:]
+}