From b3a3fdf9a447bd2b3f862380d87c675138da78e7 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 8 Apr 2015 23:03:47 +0200 Subject: Support for import/export hex encoded keys, closes #635 --- common/bytes.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common/bytes.go') diff --git a/common/bytes.go b/common/bytes.go index 5bdacd810..ba180ac94 100644 --- a/common/bytes.go +++ b/common/bytes.go @@ -147,6 +147,18 @@ func Hex2Bytes(str string) []byte { return h } +func HexBytes2Bytes(d []byte) []byte { + r := make([]byte, hex.DecodedLen(len(d))) + hex.Decode(r, d) + return r +} + +func Bytes2HexBytes(d []byte) []byte { + r := make([]byte, hex.EncodedLen(len(d))) + hex.Encode(r, d) + return r +} + func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) { if len(str) > 1 && str[0:2] == "0x" && !strings.Contains(str, "\n") { ret = Hex2Bytes(str[2:]) -- cgit v1.2.3