aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-20 19:05:26 +0800
committerobscuren <geffobscura@gmail.com>2014-08-20 19:05:26 +0800
commit55a2f35a648ef70cdcc88bd751265e30831b54e5 (patch)
tree7d5fef53c640eabf599e74873cb3c6e32d046607 /ethutil
parentb97ea0e447c24c0a85f63a7714a2eb221a7faccd (diff)
downloadgo-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.tar
go-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.tar.gz
go-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.tar.bz2
go-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.tar.lz
go-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.tar.xz
go-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.tar.zst
go-tangerine-55a2f35a648ef70cdcc88bd751265e30831b54e5.zip
JS Filter
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/bytes.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/ethutil/bytes.go b/ethutil/bytes.go
index 49fc229d3..63c1606c2 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -173,6 +173,28 @@ func LeftPadBytes(slice []byte, l int) []byte {
return padded
}
+func LeftPadString(str string, l int) string {
+ if l < len(str) {
+ return str
+ }
+
+ zeros := Bytes2Hex(make([]byte, (l-len(str))/2))
+
+ return zeros + str
+
+}
+
+func RightPadString(str string, l int) string {
+ if l < len(str) {
+ return str
+ }
+
+ zeros := Bytes2Hex(make([]byte, (l-len(str))/2))
+
+ return str + zeros
+
+}
+
func Address(slice []byte) (addr []byte) {
if len(slice) < 20 {
addr = LeftPadBytes(slice, 20)