github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/binary/byteslice.go (about)

     1  // Copyright Monax Industries Limited
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package binary
     5  
     6  func Fingerprint(slice []byte) []byte {
     7  	fingerprint := make([]byte, 6)
     8  	copy(fingerprint, slice)
     9  	return fingerprint
    10  }
    11  
    12  func IsZeros(slice []byte) bool {
    13  	for _, byt := range slice {
    14  		if byt != byte(0) {
    15  			return false
    16  		}
    17  	}
    18  	return true
    19  }
    20  
    21  func RightPadBytes(slice []byte, l int) []byte {
    22  	if l < len(slice) {
    23  		return slice
    24  	}
    25  	padded := make([]byte, l)
    26  	copy(padded[0:len(slice)], slice)
    27  	return padded
    28  }
    29  
    30  func LeftPadBytes(slice []byte, l int) []byte {
    31  	if l < len(slice) {
    32  		return slice
    33  	}
    34  	padded := make([]byte, l)
    35  	copy(padded[l-len(slice):], slice)
    36  	return padded
    37  }