Convert a byte slice to address

This commit is contained in:
obscuren 2014-07-16 13:20:57 +02:00
parent 8820d4e5ac
commit 14c4f06100

View File

@ -149,3 +149,13 @@ func LeftPadBytes(slice []byte, l int) []byte {
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
}