You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
472 B

10 years ago
10 years ago
10 years ago
  1. package common
  2. func Fingerprint(slice []byte) []byte {
  3. fingerprint := make([]byte, 6)
  4. copy(fingerprint, slice)
  5. return fingerprint
  6. }
  7. func RightPadBytes(slice []byte, l int) []byte {
  8. if l < len(slice) {
  9. return slice
  10. }
  11. padded := make([]byte, l)
  12. copy(padded[0:len(slice)], slice)
  13. return padded
  14. }
  15. func LeftPadBytes(slice []byte, l int) []byte {
  16. if l < len(slice) {
  17. return slice
  18. }
  19. padded := make([]byte, l)
  20. copy(padded[l-len(slice):], slice)
  21. return padded
  22. }