mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-20 14:59:26 +00:00
Moved string util
This commit is contained in:
parent
d5d2efbaf3
commit
d8c0b0c899
1 changed files with 23 additions and 0 deletions
23
util.go
Normal file
23
util.go
Normal file
|
|
@ -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[:]
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue