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.

34 lines
596 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 IsZeros(slice []byte) bool {
  8. for _, byt := range slice {
  9. if byt != byte(0) {
  10. return false
  11. }
  12. }
  13. return true
  14. }
  15. func RightPadBytes(slice []byte, l int) []byte {
  16. if l < len(slice) {
  17. return slice
  18. }
  19. padded := make([]byte, l)
  20. copy(padded[0:len(slice)], slice)
  21. return padded
  22. }
  23. func LeftPadBytes(slice []byte, l int) []byte {
  24. if l < len(slice) {
  25. return slice
  26. }
  27. padded := make([]byte, l)
  28. copy(padded[l-len(slice):], slice)
  29. return padded
  30. }