JS Filter

This commit is contained in:
obscuren
2014-08-20 13:05:26 +02:00
parent b97ea0e447
commit 55a2f35a64
3 changed files with 53 additions and 8 deletions

View File

@ -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)