Convert a byte slice to address

This commit is contained in:
obscuren 2014-07-16 13:20:57 +02:00
parent 8820d4e5ac
commit 14c4f06100
1 changed files with 10 additions and 0 deletions

View File

@ -149,3 +149,13 @@ func LeftPadBytes(slice []byte, l int) []byte {
return padded return padded
} }
func Address(slice []byte) []byte {
if len(slice) < 20 {
slice = LeftPadBytes(slice, 20)
} else if len(slice) > 20 {
slice = slice[len(slice)-20:]
}
return slice
}